2
export async function getStaticPaths() { 
 // Call an external API endpoint to get posts
 const res = await fetch('https://.../posts')
 const posts = await res.json()

 // Get the paths we want to pre-render based on posts
 const paths = posts.map((post) => `/posts/${post.id}`)

 // We'll pre-render only these paths at build time.
 // { fallback: false } means other routes should 404.
 return { paths, fallback: false }
}

我对这件事很好奇;在Next.JS 文档中,预渲染将获取所有帖子并将其映射以根据 id 查找数据。

当帖子总数超过一百万时,这会影响性能吗?

4

0 回答 0