Uh oh!
There was an error while loading. Please reload this page.
feat(pages)!: explicitly allow optional params with [[ - #4537
Conversation
✅ Deploy Preview for nuxt3-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
This seems a good change but I guess it is not completely resolving nuxt/nuxt#13408 considering we might have more than one optional param in the path... (Side note: Both server routes and vue-router does not have this consideration that "last dynamic segment is necessarily optional". i was unaware even we were doing this!) |
danielroe
commented
Apr 23, 2022
@pi0 How about we change the default to non-optional at end of route, and use double brackets - e.g. |
pi0
commented
Apr 25, 2022
Double bracket seems a nice idea! |
[slug]/index.vue param should be optional[[atinux
commented
Apr 25, 2022
I love this idea! |
Happy to merge once the documentation is updated. Any blockers @pi0 ? |
Resolvesnuxt/nuxt#13408. Also see nuxt/nuxt#13788.
❓ Type of change
📚 Description
Currently routes ending in a dynamic param are marked as optional, e.g.:
~/pages/[slug].vue.This PR instead requires double bracket syntax to enable optional params: e.g.
~/pages/[[slug]].vue. (This also means you can enable optional parameters earlier in the path.)👉 Migration
If you are relying on
[slug]at the end of a route to generate an optional parameter, you will need to rewrite it as[[slug]].