Home

Issue: 1875

Unable to have ignored parameters in a dynamic route

[issue link]

I’m trying to setup routes to display a given user post (named snap in my case).
The route to show a specific post is /{user}/snap/{idSnap}.

Now, to make it more friendly I want the user to be able to link to that post by adding a totally optional (and not used at all) slug after that url.
So the user should be able to see that same post by going to /{user}/snap/{idSnap}/{slugSnap}.

I tried too many directory and filename configurations, but unfortunately cannot find a way to make it work so that:

  • The user can go to /usertest/snap/12,
  • The user cannot go to /usertest/snap, and
  • The /usertest/snap/12/slugfoo url works.

This is the last directory configuration I tried so far:
nuxt_routing_hell

Moreover, in all the configurations I tried, since the documentation states that in order to make a parameter mandatory you need to create an index.vue file in the param directory, is it possible to have the /usertest/snap/12 and /usertest/snap/12/slugfoo urls points to the same component?

Thanks!

This question is available on Nuxt.js community (#c1682)