Matching `/info/` and /info/something/$slug` but not `/info/something`
Is it possible to create something like this with just one route?
4 Replies
eager-peach•2w ago
No.
correct-apricot•2w ago
I mean, you can make a match for this, but it would just be
Personally, I would just make three routes
If all of these share a layout, you can make a
route.ts in the info folder to have a shared layout, and if something/$slug is not a child of something, then you need to make sure that the file is named something_.$.ts so that something is not a parent route
Actually sorry, I mis-read your question, you don't want /info/something
I think you can just do
underscore before the . signifies that it should act as one match. You will still require two routes though. It probably helps if you can indicate what you expect the behaviour to be? is /info/ completely unrelated to /info/something/$slug or does it act as a layout. you will require two routes either way (but the structure you use would change based on the requirements)exotic-emeraldOP•2w ago
Yes, I'd like to have something like this
/blog (shows all categories)
/blog/categories/$slug shows posts per category
/blog/$slug shows specific blog post
UI in both blog and blog/categories/how-to would be exactly the same we would just mark tab how-to as active
I know I can create 2 routes and extract whole content to a separate component however thought there is awaycorrect-apricot•2w ago
Personal I think 3 at minimum will make your life easier in the long run