i18n icon indicating copy to clipboard operation
i18n copied to clipboard

`og:url` is added twice, instead of being overwritten

Open TheDutchCoder opened this issue 1 year ago • 3 comments
trafficstars

Environment



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

TheDutchCoder avatar Jan 03 '24 18:01 TheDutchCoder

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.

BobbieGoede avatar Feb 13 '24 17:02 BobbieGoede

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.

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.

TheDutchCoder avatar Feb 14 '24 12:02 TheDutchCoder

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.

BobbieGoede avatar Feb 14 '24 13:02 BobbieGoede