-
-
Notifications
You must be signed in to change notification settings - Fork 488
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
Dynamic Routes in Nuxt 3 #2429
Comments
Hi, Also an Idea would be to change the copy of the doc from:
to possible version: Best, |
While your point is correct and the dynamicRouteParams needs to be set correctly (to true), this isn't the point of my ticket. Dynamic slug translation doesn't work at all for now. Unless you're hardcoding it in the code (which isn't a use-case in production). That's why it's added as a feature for the stable release (v8). |
@TomKremer I just checked. The documentation is inside this repo and will be generated from here. Why you don't create a pull request with the adjusted documentation text? |
voilà #2454 |
@kazupon Is there any updates for this feature? As mentioned above if you're building a large application - having all translated dynamic slugs hardcoded as strings is not viable. |
i came from this issue: #2100 Dynamic routes works with
This doesnt work const enUrl = 'first-route'
const frUrl = 'second-route'
definePageMeta({
nuxtI18n: {
en: { url: enUrl },
fr: { url: frUrl }
}
}) The problem is that in large applications, as in my case, the routes are given from a backend. My backend gives me the route for each language but it is impossible for me to specify it to nuxti18n. |
For lack of a better way, I currently set the routes like this in the useRoute().meta.nuxtI18n = {
en: { slug: [getSlugByLanguage('en')] },
de: { slug: [getSlugByLanguage('de')] },
fr: { slug: [getSlugByLanguage('fr')] },
it: { slug: [getSlugByLanguage('it')] }
}
|
At the moment its the only & best way to handle this situation. Much thanks @scherii |
I also gave it a try, it works but only client-side if I'm correct? The page is still served with incorrect meta. Could anyone check if their page is served correctly? Many Thanks! |
@TomKremer |
Hi @TomKremer Yes, the
This should work on both the client and server sides. Until #2580 is ready you would have to set this manually as well (through const i18nHead = useLocaleHead({ addSeoAttributes: true })
useHead({
htmlAttrs: { lang: i18nHead.value.htmlAttrs.lang },
link: [...i18nHead.value.link],
meta: [...i18nHead.value.meta]
})
useSeoMeta({
// see https://nuxt.com/docs/api/composables/use-seo-meta
}) |
With #2580 merged and released in Try out the new If you run into any bugs please open a new issue with a minimal reproduction 💪 |
Describe the feature
Hey there,
I don't know if for my issue there's already a working solution. At least I don't get it to work for now.
I'm now working with Nuxt 3 (@nuxtjs/i18n: 8.0.0-rc.4) and in the process of upgrading from Nuxt 2.
I have dynamic routes with a slug/url that is translated and changes per language.
Before I was able to dispatch those params like this:
In the new version, I don't see such an option. Also since VueX also isn't the default (I'm using Pinia now as well). But how is it possible to push the slug to the route somehow and the package is resolving it with
switchLocalePath
?In the documentation there's something mentioned about "Custom route paths", but it still doesn't make sense to me how to add those dynamic values.
Something like that and then the second part the actual
name
param is missing to me.Thanks and would appreciate it if somebody has experience with this feature.
Additional information
Final checks
The text was updated successfully, but these errors were encountered: