This test supports a hyopthetical number of dynamic paths. The path param is id
, and we're supporting IDs 1 - 5. IDs 1 - 5 will be returned from getStaticPaths. We've set fallback: false
in getStaticPaths, meaning that any other id should result in a 404.
export async function getStaticPaths() {
return {
paths: [
{
params: { id: '1' }
},
{
params: { id: '2' }
},
{
params: { id: '3' }
},
{
params: { id: '4' }
},
{
params: { id: '5' }
}
],
fallback: false,
};
}
export async function getStaticProps(context) {
const id = context.params.id;
return {
props: {
id,
},
revalidate: 2,
};
}