Skip to content

Instantly share code, notes, and snippets.

@danielotieno
Created July 31, 2023 18:58
Show Gist options
  • Save danielotieno/24a638eac781d6054ee2b5b0e4b37d50 to your computer and use it in GitHub Desktop.
Save danielotieno/24a638eac781d6054ee2b5b0e4b37d50 to your computer and use it in GitHub Desktop.
export default function Article({ article }) {
return (
<>
<h3>{article.title}</h3>
<br />
<Link href='/'>Go Back</Link>
</>
);
}
export const getStaticProps = async (context) => {
const {
params: { slug },
} = context;
const article = yourArticleData.find((item) => item.id === id);
return {
props: {
article,
},
};
};
export const getStaticPaths = async () => {
const ids = yourArticleData.map((article) => article.id);
const paths = ids.map((id) => ({ params: { id: id } }));
return {
paths,
fallback: false,
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment