Urara-Blog/node_modules/.pnpm-store/v3/files/e2/e46375ce735070f58319285ca2339d8afeada001a45209c859ff910b3bee091cae667acaf245869c975e00990c31938617ae8dfe11217b784d58e0e5b9e7f2
2022-08-14 01:14:53 +08:00

26 lines
506 B
Text

// posts will be populated at build time by getStaticProps()
function Blog({ posts }) {
return (
<ul>
{posts.map((post) => (
<li>{post.title}</li>
))}
</ul>
)
}
// This function gets called at build time on server-side.
export async function getStaticProps() {
const res = await fetch('https://.../posts')
const posts = await res.json()
return {
props: {
posts
}
}
}
export default Blog
// From https://nextjs.org/docs/basic-features/data-fetching