nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.75k stars 483 forks source link

`useSetI18nParams` and `useLocaleHead` `rel="alternate"` aren't sync. #2779

Open luca-smartpricing opened 9 months ago

luca-smartpricing commented 9 months ago

Environment


Reproduction

https://stackblitz.com/edit/github-c7te5q-rzxba2

Describe the bug

useLocaleHead doesn't work with useSetI18nParams because <link rel="alternate" /> aren't sync.

Additional context

if i go from Homepage /it to the blog page /it/blog-1-ita using the Go at Blog Page button, the alternate links don't change; but i've set all the i18nParams

setI18nParams({
    it: { blog: 'blog-1-it' },
    de: { blog: 'blog-1-de' },
    en: false,
})

If i refresh the page when i'm in the blog page, the <link rel="alternate" /> are duplicated (and also canonical).

<link rel="alternate" href="https://www.dummy.com/en/blog-1-ita" hreflang="en" data-hid="7fcee50">
<link rel="alternate" href="https://www.dummy.com/it/blog-1-ita" hreflang="it" data-hid="08fce45">
<link rel="alternate" href="https://www.dummy.com/de/blog-1-ita" hreflang="de" data-hid="5d718b2">
<link rel="alternate" href="https://www.dummy.com/it/blog-1-ita" hreflang="x-default" data-hid="6527e7a">
<link rel="canonical" href="https://www.dummy.com/it/blog-1-ita" data-hid="5cca6f5">

<link id="i18n-alt-it" rel="alternate" href="https://www.dummy.com/it/blog-1-it" hreflang="it">
<link id="i18n-alt-de" rel="alternate" href="https://www.dummy.com/de/blog-1-de" hreflang="de">
<link id="i18n-xd" rel="alternate" href="https://www.dummy.com/it/blog-1-it" hreflang="x-default">
<link id="i18n-can" rel="canonical" href="https://www.dummy.com/it/blog-1-ita">

Logs

No response

BobbieGoede commented 9 months ago

See https://github.com/nuxt-modules/i18n/issues/2749 for details on why this happens, we're working on it.