-
-
Notifications
You must be signed in to change notification settings - Fork 490
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
fix: definePageMeta
name overriding localized route name
#2603
fix: definePageMeta
name overriding localized route name
#2603
Conversation
definePageMeta
name overriding localized route namedefinePageMeta
name overriding localized route name
6a38c86
to
ecfba48
Compare
@BobbieGoede Thanks!
Your PR looks good! However, this approach is more of a workaround & hack. @danielroe |
I agree it does feel hacky, my initial solution was #2599 but the drawback is that users would have to avoid using The solution in this PR requires no changes in code or usage for users, but the drawback being that it's more likely to break. Personally I think the best solution would be to change the generated file from Nuxt's side, the way some data from
|
I think we might consider reworking Nuxt implementation so we actually expose some page metadata at build-time (via |
Closing this as it would break if changes are made upstream, will keep an eye on nuxt/nuxt#24770 and if I have time later (maybe next year 😅) I'll see if I can work on resolving that. |
🔗 Linked issue
definePageMeta({ name: ... })
breaks route generation #2581❓ Type of change
📚 Description
While trying to figure out bundler plugins I figured there was an alternative way to tackle #2581. Maybe this is easier to break by Nuxt updates, but I feel this solution makes more sense than #2599. I still need to test this with disabled routes, and I may be missing other edge cases, please let me know.
What this PR does is transform the generated
routes.mjs
file, instead lettingname
defined indefinePageMeta
override the localized name (see source code), we capture the locale route name suffix and combine it with the name if it exists, this makes named routes work as expected.So in
routes.mjs
the generation would be changed like this exampleWhat do you think @kazupon?
📝 Checklist