When I change the folder [slug] name from: app/posts/[slug]/page.tsx http://localhost:3000/posts/change-me **Works!.** to: app/posts/[...slug]/page.tsx http://localhost:3000/posts/myfolder/test **Doesn't Work!.** I've created mdx file in posts/myfolder/test.mdx I got some errors: Error: A required parameter (slug) was not provided as an array received string in generateStaticParams for /posts/[...slug] I'm testing from: https://github.com/contentlayerdev/next-contentlayer-example/ Should i edit `contentlayer.config.ts` or `app/posts/[slug]/page.tsx` ?
Activity
mkalsi25 commentedon May 6, 2023
To use "catch all segment", you need to pass slug value in array format in generateStaticParams.
In your case, you need to edit your file
app/posts/[...slug]/page.tsxsomething like that:To find data using slug.
More info: https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes#catch-all-segments
I hope it make sense. Happy coding 👨🏻💻