i18n
i18n copied to clipboard
`og:url` is added twice, instead of being overwritten
Environment
- Operating System: Darwin
- Node Version: v20.7.0
- Nuxt Version: 3.9.0
- CLI Version: 3.10.0
- Nitro Version: 2.8.1
- Package Manager: [email protected]
- Builder: -
- User Config: devServer, app, components, css, devtools, modules, nitro, runtimeConfig, srcDir, vite
- Runtime Modules: @nuxtjs/[email protected], @nuxtjs/[email protected], @nuxtjs/[email protected], @nuxtjs/[email protected], [email protected]
- Build Modules: -
Reproduction
https://stackblitz.com/edit/bobbiegoede-nuxt-i18n-starter-yoyts6?file=pages%2Findex.vue
Describe the bug
When trying to set the og:url on a page, instead or merging the properties, this module actually just adds it to the array and due to that, two og:url meta elements end up in the source of the page.
Additional context
Open the Stackblitz page in a New Tab so you ca inspect the source.
Logs
No response
This isn't really a bug but it should be documented better, by default useLocaleHead adds hid properties to the i18n meta tags (configurable with attributeIdentifier), this is actually used to identify and prevent duplicates.
If you add the same hid property to the og:url tag you can overwrite it. I have changed your reproduction to demonstrate here.
This isn't really a bug but it should be documented better, by default
useLocaleHeadaddshidproperties to the i18n meta tags (configurable withattributeIdentifier), this is actually used to identify and prevent duplicates.If you add the same
hidproperty to theog:urltag you can overwrite it. I have changed your reproduction to demonstrate here.
I understand that, but Nuxt 3 explicitly tells you that hid is no longer a thing, so people will generally not know this (or use this): https://nuxt.com/docs/migration/meta#migration.
I think it would be better to dedupe entries by default.
Personally, I agree that deduping by default would be more intuitive, something to consider for v9 as it is a breaking change. For v8 an option could be to allow passing attributeIdentifier: false to disable using an identifier for deduplication, will need to explore whether this works as expected.