Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[...slug] pages has higher priority in sub directories #14117

Closed
farnabaz opened this issue Jun 9, 2022 · 2 comments · Fixed by nuxt/framework#4983
Closed

[...slug] pages has higher priority in sub directories #14117

farnabaz opened this issue Jun 9, 2022 · 2 comments · Fixed by nuxt/framework#4983

Comments

@farnabaz
Copy link
Member

farnabaz commented Jun 9, 2022

Environment

------------------------------
- Operating System: `Linux`
- Node Version:     `v16.14.2`
- Nuxt Version:     `3.0.0-rc.3`
- Package Manager:  `npm@7.17.0`
- Builder:          `vite`
- User Config:      `-`
- Runtime Modules:  `-`
- Build Modules:    `-`
------------------------------

Reproduction

https://stackblitz.com/edit/nuxt-starter-r2xyxg

Describe the bug

Having a [...slug] page in a subdirectory (let's say blog/[...slug].vue had higher priority than other routes that were defined in the same directory

For example I have blog/index.vue and blog/[...slug].vue, visiting http://localhost:3000/blog always renders blog/[...slug].vue.
Non-dynamic routes should have higher priority than dynamic routes like [...slug].

Just to mention, if I move index.vue and [...slug].vue out of the subdirectory and place them inside pages dir, it works as expected.

Additional context

No response

Logs

No response

@danielroe
Copy link
Member

danielroe commented Jun 9, 2022

Thanks for the more details - this would be resolved with nuxt/framework#4983.

This is vue-router behaviour: https://paths.esm.dev/?p=AAMeJYyAwQYc7ALcM-AKtADvDlBUgFECFOAwBFAsAAA.# and it may be worth raising an issue at https://github.com/vuejs/router and getting @posva's take on this for whether it should be resolved in vue-router itself (vuejs/router#1435).

@posva
Copy link
Collaborator

posva commented Jun 9, 2022

Yes, this a vue-router bug. Note routes like /blog/:id? and /blog/:id* will still have a higher priority than /blog because in that case the path /blog matches both but order does not depend on the path that is being matched. It solely depends on the giving path pattern (e.g. /blog/:id). In practice, with full control of the router, one could avoid this with /blog/:slug(.+) but I understand that's not how [...slug] works.

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants