Created
July 31, 2023 18:58
-
-
Save danielotieno/24a638eac781d6054ee2b5b0e4b37d50 to your computer and use it in GitHub Desktop.
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
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