Does next.js supports two dynamic router directories?
Answered
Chipping Sparrow posted this in #help-forum
Chipping SparrowOP
/app
/how-to
/[slug]
page.tsx
/page-[pageNumber]
page.tsxI have a content under
slug directory, but I want to implement pagination as /how-to/page-1, /how-to/page-2 and so on. Can I use next. js like that? Or do I need to add business logiс in [slug]/page.tsx to hande this case?Answered by Clown
No you cannot do partial matching like that and you cant have two dynamic routes on the same level.
3 Replies
@Chipping Sparrow
/app
/how-to
/[slug]
page.tsx
/page-[pageNumber]
page.tsx
I have a content under `slug` directory, but I want to implement pagination as `/how-to/page-1`, `/how-to/page-2` and so on. Can I use next. js like that? Or do I need to add business logiс in `[slug]/page.tsx` to hande this case?
No you cannot do partial matching like that and you cant have two dynamic routes on the same level.
Answer
You can try and parse the slug and do conditional rendering however and use
notFound() on everything elseChipping SparrowOP
thank u very much