Closed UfukUstali closed 1 year ago
Hi! Thanks for the report i'll look into this
I did a little more digging and the situation seems to be different then what i described above.
export type RoutePathSchema =
"/"|"/de/catagories/:slug"|"/de/catagories"|"/de/"|"/de/me/"|"/de/search"|"/de/signin"|"/de/verify-request"|"/en/catagories/:slug"|"/en/catagories"|"/en/"|"/en/me/"|"/en/search"|"/en/signin"|"/en/verify-request"|"/fr/catagories/:slug"|"/fr/catagories"|"/fr/"|"/fr/me/"|"/fr/search"|"/fr/signin"|"/fr/verify-request"|"/me/"|"/signin"|"/tr/"|"/tr/catagories/:slug"|"/tr/catagories"|"/tr/me/"|"/tr/search"|"/tr/signin"|"/tr/verify-request"|"/verify-request"
;
The RoutePathSchema is also missing the "/catagories" and "/catagories/:slug" fields. I was able to track it down until walkRoutes.ts file:
if (parent?.path !== "/") {
output.routesPaths.push({
name: route.name,
path: newPath,
isLocale: isLocaleRoute,
});
}
This if statement was preventing the generation of the routes directly under index "/" thereby all of the following were not generated ["/catagories/:slug", "/catagories", "/search"]
. The locale variations were not effected because their parent is technically "/en" or "/de" and so on. But when removed it causes the index route to be generated twice simply because i have a child route index under the root index route. e.g. ["/", "/", "/catagories/:slug", "/catagories", "/me/", "/search", "/signin", "/verify-request"]
pages βββ index <- from here β βββ catagories β β βββ [slug].vue β β βββ index.vue β βββ index.vue <- the second index route was only generated after the modification β βββ search.vue <- untill here was not generated unless it was locale route βββ index.vue < first index route was generated originally βββ me β βββ index.vue βββ me.vue βββ signin.vue βββ verify-request.vue
This was the final solution i ended up that i think doesn't cause any issues
if (parent?.path !== "/" || newPath !== parent?.path) {
output.routesPaths.push({
name: route.name,
path: newPath,
isLocale: isLocaleRoute,
});
}
Do you want to make a PR or do you want me to udpate it? :) Thanks for the finding!
Just opened the PR
Describe the bug Some routes that are in the RoutePathSchema are not included in the LocaleRoutePathSchema
As can be seen in the above example the "/catagories" and "/catagories/:slug" are not included in the LocaleRoutePathSchema. It is only the type that is broken when I pass "/catagories" to somewhere where the LocalRoutePathSchema is the type it functions without an issue.
On a completely unrelated matter could you guys take a look at my other issue on the nuxt i18n repo. It's about the newly introduced NuxtLinkLocale component.
Expected behavior LocaleRoutePathSchema should be identical to RoutePathSchema other than the fact that it should not include all of the locale variations.
Environnement infos
Build Modules: -
Your
pages
folder structurepages βββ index β βββ catagories β β βββ [slug].vue β β βββ index.vue β βββ index.vue β βββ search.vue βββ index.vue βββ me β βββ index.vue βββ me.vue βββ signin.vue βββ verify-request.vue
Your nuxt.config.ts