Repository navigation
fix(unhead): dedupe <link rel="alternate"> - #655
Conversation
Co-authored-by: onmax <[email protected]>
Bundle Size Analysis
|
|
Great stuff, thanks :) |
| return 'canonical' | ||
|
|
||
| if (name === 'link' && props.rel === 'alternate') { | ||
| return `alternate:${props.hreflang || props.type || 'x-default'}:${props.href || ''}` |
There was a problem hiding this comment.
If I understand correctly, with this change alternate links are only deduplicated if their href are identical, but prevents deduplication based on key or id.
Is there a specific reason for including the href in the dedupe key?
| return `alternate:${props.hreflang || props.type || 'x-default'}:${props.href || ''}` | |
| return `alternate:${props.hreflang || props.type || 'x-default'}` |
There was a problem hiding this comment.
this was just meant to dedupe for hydration purposes
does a custom key not work?
There was a problem hiding this comment.
oh ye probably don't need href, any exactinsights for what we need @BobbieGoede 🙏 mindful of breaking any i18n features
There was a problem hiding this comment.
This change breaks functionality in i18n for localized dynamic parameters, these translations are fetched/updated at a later point:
<link id="i18n-alt-nl" rel="alternate" href="http://localhost:3000/nl/products/big-chair" hreflang="nl">
<link id="i18n-alt-nl" rel="alternate" href="http://localhost:3000/nl/products/grote-stoel" hreflang="nl">I was using id to ensure deduplication which is broken now, but I think removing href from the dedupe key should allow for deduplication without it (not only deduplicating duplicate urls).
There was a problem hiding this comment.
@danielroe your change prevents the key and id logic from being reached below, so it breaks custom keys: 38815ec#diff-bdce5db600ceed2c1bafdfa8fbc98c0e3f948c2db00fe2b0bac0611a54d856bbR53-R59
There was a problem hiding this comment.
maybe just move it below custom key logic?
There was a problem hiding this comment.
I think moving it below would work, but I also think removing href from the key makes sense, at least for alternate links with a hreflang.
There was a problem hiding this comment.
return alternate:${props.hreflang || props.type || 'x-default'} this looks good to me and can land a release for it if it works for you @BobbieGoede
There was a problem hiding this comment.
that works for nuxt-i18n, just ran the tests locally with that change @harlan-zw
There was a problem hiding this comment.
my apologies for this!
😢
🔗 Linked issue
resolves nuxt/nuxt#32670
closes nuxt/nuxt#34150
❓ Type of change
📚 Description
previously
rel=alternatelinks were not deduped and on hydration would be duplicated