harlan-zw / nuxt-seo

The complete SEO solution for Nuxt.
https://nuxtseo.com
1.02k stars 63 forks source link

[Sitemap] Support dynamic i18n route keywords #307

Open Bombastickj opened 1 week ago

Bombastickj commented 1 week ago

Describe the bug

Hi,

I've been attempting to create a correctly translated sitemap in Nuxt 3 using the @nuxt/sitemap module, but I'm facing some difficulties with dynamic routes. Below is the summary of my discussion with @harlan-zw:

Issue Summary

Reproductions

  1. Initial Setup: Minimal Reproduction Example Expected behavior: Three entries in each translated sitemap.

  2. Missing Homepage / Incorrectly Inferred Dynamic Routes: Minimal Reproduction Example

  3. Multi-Sitemap Configuration: Multi-Sitemap Example Issue: hreflangs remain zero.

  4. Using defineI18nRoute: Example with defineI18nRoute Issue: Dynamic routes still don't get translated properly.

Request

Could you please investigate the support for translating dynamically generated i18n routes in the @nuxt/sitemap module?

Additional Information

For the time being, I'm using defineI18nRoute with partial success but still facing issues with dynamic routes. Any suggestions or potential fixes would be highly appreciated.

Thank you for your assistance and looking forward to a resolution!

Best regards, Jonas

Reproduction

https://stackblitz.com/edit/nuxt-starter-nc3hjd?file=nuxt.config.ts

System / Nuxt Info

No response

harlan-zw commented 1 week ago

Needs to support Nuxt I18n path matching with the Nuxt pages features:

-| pages/
---| index.vue
---| users-[group]/
-----| [id].vue
-| pages/
---| index.vue
---| (marketing)/
-----| about.vue
-----| contact.vue

I18n reference: https://i18n.nuxtjs.org/docs/guide/custom-paths#example-3-dynamic-routes

harlan-zw commented 6 days ago

Just a small update on this, I did start investigating and was confirmed in my suspicious that it was going to be quite painful. So will need to try again when I have a good time to sit down with it.