Next.jsと
"next": "^10.0.5",
"typescript": "^4.1.3"基本的に
getStaticProps関数を
export const getStaticProps = async () => {
return {
props: {
posts: await getPosts() // 投稿を取得
}
}
}各投稿ページもgetStaticPaths, getStaticProps関数を
export const getStaticPaths: GetStaticPaths = async () => {
return {
fallback: false,
paths: await getPaths() // 記事のパスを取得
}
}
export const getStaticProps: GetStaticProps<Props> = async ({ params }) => {
return {
props: {
post: await getPost(params?.id) // 記事を取得
}
}
}静的ファイルを
next exportSSGに
next build
next startすごく
次は