-
-
Notifications
You must be signed in to change notification settings - Fork 483
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
Not playing nice with router.extendRoutes
#1280
Comments
Without investigating too much, maybe it would work for you to set the |
Yeah, that's what I'm using for most pages. I forgot to add some details to justify my setup. I'm using ignored pages (four different kinds) to generate pages at the root level. They're landings the marketing team uses to onboard new users and I have no way to know where they'll go except at build time when I fetch them from the CMS. Let me know if this makes it clearer or you have any more questions. I can provide more details if that's the case 👍 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
not stale |
Same issue here, we are using _.vue to fetch pages from an API based on the page path. Together with the prefix_and_default strategy and without a default locale, the route to _.vue is gone. Manually defining that route via extendRoutes isn't working. |
is there any progress on this issue? |
+1 |
Same issue |
try to use hooks like so:
|
Closing this as v7 is not being actively worked on (critical hotfixes only), if this still applies to v8 and later please open a new issue! |
Some projects will fetch data from an external source and use
router.extendRoutes
to create pages based on the source's response contents. In my case I fetch the data from Sanity and, given a_type
andslug
, I'll generate a page using one of my ignored page components.Before adding
@nuxtjs/i18n
to my project, I was able to pass an array of route objects and Nuxt was using to create the pages I wanted. With this module enabled, Nuxt will try to render all of those pages for each of the available locales.This is what doesn't work as expected (plus I couldn't find any examples of using the module like this). I have a PR ready for review (#1281) that is solving this issue on my local env. Since I'm not familiar with the codebase and all the ins and outs of the module I'm opening this issue first.
Version
@nuxtjs/i18n: v7.0.3
nuxt: v2.15.8
Nuxt configuration
nuxt generate
)@nuxtjs/i18n configuration
Object.entries(Object.fromEntries())
, my config is split in two parts and one of them is shared accross different projects and I just copy/pasted the relevant parts for the issue.Reproduction Link
https://codesandbox.io/s/test-nuxt-i18n-forked-2us3p
Steps to reproduce
vue-devtools
, you should se something like this:What is Expected?
I expect
@nuxtjs/i18n
to either:What is actually happening?
The module is assuming each of those routes needs their localized counter parts and pushing them to the router. This breaks the theme-switcher functionality and pushes non-existent pages to the router, resulting in one build error for each of those.
It also prefixes the paths with each locale, resulting in some cases in a duplicated locale. Looks like this only happens because the module doesn't expect someone to provide custom routes.
I tried with different name routes, including/excluding the locale on the name route, and a bunch of other things. The approach shown on the config section of this issue is what made the most sense to me since it consist of manually writing the same route Nuxt and the module would generate for me.
The text was updated successfully, but these errors were encountered: