Skip to content

Instantly share code, notes, and snippets.

@fivepixels
Last active June 16, 2023 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fivepixels/e4d72476e926ecfe4777e9515abc2c1f to your computer and use it in GitHub Desktop.
Save fivepixels/e4d72476e926ecfe4777e9515abc2c1f to your computer and use it in GitHub Desktop.
SSG Next JS Page
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