Open EvilaMany opened 11 months ago
Would you be able to provide a reproduction? 🙏
Reproduction: https://stackblitz.com/edit/github-g8bh9l
Maybe I misunderstand, but wouldn't the /cats
page have different content from the /dogs
page? Which would have its own translations?
Not really. My app should have multiple pages with the almost same layout and view, but different urls and translations based on url it resolved by. This differences will lay deeply inside page, in few components. All the other content are the same. Also there are should be possibility to change url to another alias, without rerendering the page itself. I need to rerender only content in components with url based content, but all the other page with inputs etc should save state. So it make sense to make computed-s based on current route.pathname (alias), instead of creating N separate pages
Mostly it's SEO tricks, so I recommend not to find logic here (=
You can use hooks like this:
export default defineNuxtConfig({
hooks: {
'pages:extend'(pages) {
pages.push({
name: `dogs-info`,
path: `/dogs-info`,
file: resolve(__dirname, 'pages/index.vue')
});
pages.push({
name: `cats-info`,
path: `/cats-info`,
file: resolve(__dirname, 'pages/index.vue')
});
}
}
})
Describe the feature
My app has only 1 page, that should have many possible urls to be resolved by (for SEO purposes). The page should only change some translations depending on url it was resolved by. I created single pages/index.vue and set definePageMeta({ alias... }). But nuxti18n generate only localised route for main page url, not for any of aliases.
For example I have two aliases: /dogs-info /cats-info
In pages/index.vue I set alias as follows
definePageMeta({ alias: ["/dogs-info", "/cats-info"] })
I expect that I will have routes: / /pl /es /dogs-info (default locale) /cats-info (default locale) /pl/dogs-info /pl/cats-info /es/cats-info /es/dogs-info
But I have only: / /pl /es
Additional information
Final checks