This is my page tree
├── _app.tsx
├── _document.tsx
├── index.tsx
└── [type]
└── [slug].tsx
and this is the getStaticPaths for the [slug] page:
export const getStaticPaths: GetStaticPaths = async () => {
const posts = getAllPosts(["slug"]);
return {
paths: posts.map((posts) => {
return {
params: {
type: posts.mainTag,
slug: posts.slug,
},
};
}),
fallback: false,
};
};
so the a page would look like this for example
http://localhost:3000/programming/some-slug
when i go to a certain post, i get this error:
A required parameter (type) was not provided as a string in getStaticPaths for /[type]/[slug]
i just don't know how i would go about providing the type
parameter to the router.
posts.mainTag
may not be a string - can you verify it's not an object/null etc:console.info(typeof posts.mainTag)
in your map loop – Samuel Goldenbaum May 12 '20 at 20:28mainTag
? One missing will be a prob – Samuel Goldenbaum May 13 '20 at 0:10getAllPosts(["slug"]);
with a simple array to triple check:const posts = [ { mainTag: 'programming', slug: 'hello-world' }, { mainTag: 'programming', slug: 'nextjs-101' }, ];
– Samuel Goldenbaum May 13 '20 at 17:13