Last active
June 16, 2023 18:52
-
-
Save fivepixels/e4d72476e926ecfe4777e9515abc2c1f to your computer and use it in GitHub Desktop.
SSG Next JS Page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { GetStaticPaths, GetStaticProps, NextPage } from 'next'; | |
interface Project { | |
title: string; | |
id: number; | |
} | |
interface IPageProps { | |
projects: Project[]; | |
author: string; | |
} | |
const Page: NextPage<IPageProps> = ({ projects, author }) => { | |
return ( | |
<> | |
<h1>{author}</h1> | |
<div> | |
projects.map((project, idx) => ( | |
<div key={idx}>{project}</div> | |
)) | |
</div> | |
</> | |
); | |
}; | |
export const getStaticPaths: GetStaticPaths = () => { | |
// ... | |
// ... | |
// ... | |
return { | |
paths: [ | |
{ params: { id: "one" } }, | |
{ params: { id: "two" } }, | |
{ params: { id: "three" } } | |
], | |
}; | |
}; | |
export const getStaticProps: GetStaticProps = async (ctx) => { | |
// ... | |
// ... | |
// ... | |
return { props: { projects, title: "Cattynip" } } | |
} | |
export default Page; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment