That's not an entirely Prismic question, but was hoping that someone on here will let me know if this is possible.
Can I create a folder such as /pages/[folder]/[uid].js as well as /pages/[uid].js. If I do that, then it says that it can't because there are conflicting IDs since [folder] and [uid] are not the same.
For context, I want to use /pages/[uid].js for the Page custom type - for pages such as /about and contact-us while I want to dynamically create folders for content, such as /news/new-website and /resources/start-here/ dynamically.
If it's not possible, I can simple create the folders hard coded (what I've been doing up to now), such as /news/[uid].js and /resources/[uid].js but then the marketing team will need a bit of development help every time they want to create a new folder.
An alternative which I have not tried is to create a massive file using the catch-all method pages/[...uid].js but then I see that this file will become a mess, so I want to avoid it.
I've run into a similar issue recently, it does not seem possible to do that.
You can only have one dynamic page per level. I ended up restructuring the project a little bit and added everything that is dynamic under different folders
/blog/[category]/[uid]
/pages/[category]/[uid]
etc
The only problem that it generates is that the slug can't be translated. But that's a minor detail.
Thanks for the quick answer! However, I'm not sure you understood my problem. I would like to have a folder /pages/[category]/ as well as /pages/[uid].js which is on the same level
I think I agree with David that at the moment, it is not possible in Nextjs
@kris What you're trying to do might actually be possible using a catch-all along with a normal dynamic route. According to the Next.js docs, a normal dynamic route will take precedence over a catch-all route.
That means that you should be able to have your /pages/[uid].js route for your /about and /contact-us pages.
Then you could also use a catch-all route such as /pages/[...uid].js for anything with a folder such as /news/new-website.
Hi @levi , thanks a lot! That might just work - I just gave it a quick spin, but I also need to handle folder index pages (eg /news/) which are a different custom type so it will get a bit messy if I handle all of those in the same route.
Yeah handling the folder index pages makes this much more complicated. You will probably need to either hard code the folder categories as you mentioned or namespace your folder routes. Something like /pages/articles/[folder]/[uid].js.
system
(system)
closed as resolved, flag & select 'Something Else' to reopen.
11
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.