Skip to content

Commit 1d3e884

Browse files
rx-837BobbieGoede
andauthored
fix!: change default value for key property in seo functions to match Unhead v2 (#3561)
Co-authored-by: Bobbie Goede <bobbiegoede@gmail.com>
1 parent efbb210 commit 1d3e884

9 files changed

Lines changed: 17 additions & 14 deletions

File tree

‎docs/content/docs/02.guide/06.seo.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ const title = computed(() => t(route.meta.title ?? 'TBD', t('layouts.title'))
8787
<Html :lang="head.htmlAttrs.lang" :dir="head.htmlAttrs.dir">
8888
<Head>
8989
<Title>{{ title }}</Title>
90-
<template v-for="link in head.link" :key="link.hid">
91-
<Link :id="link.hid" :rel="link.rel" :href="link.href" :hreflang="link.hreflang" />
90+
<template v-for="link in head.link" :key="link.key">
91+
<Link :id="link.key" :rel="link.rel" :href="link.href" :hreflang="link.hreflang" />
9292
</template>
93-
<template v-for="meta in head.meta" :key="meta.hid">
94-
<Meta :id="meta.hid" :property="meta.property" :content="meta.content" />
93+
<template v-for="meta in head.meta" :key="meta.key">
94+
<Meta :id="meta.key" :property="meta.property" :content="meta.content" />
9595
</template>
9696
</Head>
9797
<Body>

‎docs/content/docs/02.guide/90.migrating.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ We have upgrade from Vue I18n v10 to v11, this major version bump deprecates the
1010

1111
Check the documentation detailing the breaking changes [here](https://vue-i18n.intlify.dev/guide/migration/breaking11.html).
1212

13+
### Option default changed `useLocaleHead()`{lang="ts"} and `$localeHead()`{lang="ts"}
14+
The default value for the `key` property has been changed from `'hid'` to `'key'`.
15+
1316
### Deprecate `$localeHead()`{lang="ts"}
1417
The `$localeHead()`{lang="ts"} Nuxt context function has been deprecated and will be removed in v11.
1518

‎docs/content/docs/06.composables/04.use-locale-head.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ An object accepting the following optional fields:
3232

3333
- `key`
3434
- type: `string`{lang="ts"}
35-
- default: `'hid'`{lang="ts"}
35+
- default: `'key'`{lang="ts"}
3636
- Identifier attribute of `<meta>` tag.
3737

3838
## Usage

‎specs/basic-usage-tests.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export function basicUsageTests() {
132132
)
133133

134134
expect(await page.locator('#locale-head').innerText()).toMatchInlineSnapshot(
135-
`"{ "htmlAttrs": { "lang": "en" }, "link": [ { "hid": "i18n-xd", "rel": "alternate", "href": "http://localhost:3000/nuxt-context-extension", "hreflang": "x-default" }, { "hid": "i18n-alt-en", "rel": "alternate", "href": "http://localhost:3000/nuxt-context-extension", "hreflang": "en" }, { "hid": "i18n-alt-fr", "rel": "alternate", "href": "http://localhost:3000/fr/nuxt-context-extension", "hreflang": "fr" }, { "hid": "i18n-alt-ja", "rel": "alternate", "href": "http://localhost:3000/ja/nuxt-context-extension", "hreflang": "ja" }, { "hid": "i18n-alt-ja-JP", "rel": "alternate", "href": "http://localhost:3000/ja/nuxt-context-extension", "hreflang": "ja-JP" }, { "hid": "i18n-alt-nl", "rel": "alternate", "href": "http://localhost:3000/nl/nuxt-context-extension", "hreflang": "nl" }, { "hid": "i18n-alt-nl-NL", "rel": "alternate", "href": "http://localhost:3000/nl/nuxt-context-extension", "hreflang": "nl-NL" }, { "hid": "i18n-alt-nl-BE", "rel": "alternate", "href": "http://localhost:3000/be/nuxt-context-extension", "hreflang": "nl-BE" }, { "hid": "i18n-alt-kr", "rel": "alternate", "href": "http://localhost:3000/kr/nuxt-context-extension", "hreflang": "kr" }, { "hid": "i18n-alt-kr-KO", "rel": "alternate", "href": "http://localhost:3000/kr/nuxt-context-extension", "hreflang": "kr-KO" }, { "hid": "i18n-can", "rel": "canonical", "href": "http://localhost:3000/nuxt-context-extension" } ], "meta": [ { "hid": "i18n-og-url", "property": "og:url", "content": "http://localhost:3000/nuxt-context-extension" }, { "hid": "i18n-og", "property": "og:locale", "content": "en" }, { "hid": "i18n-og-alt-fr", "property": "og:locale:alternate", "content": "fr" }, { "hid": "i18n-og-alt-ja-JP", "property": "og:locale:alternate", "content": "ja_JP" }, { "hid": "i18n-og-alt-nl-NL", "property": "og:locale:alternate", "content": "nl_NL" }, { "hid": "i18n-og-alt-nl-BE", "property": "og:locale:alternate", "content": "nl_BE" }, { "hid": "i18n-og-alt-kr-KO", "property": "og:locale:alternate", "content": "kr_KO" } ] }"`
135+
`"{ "htmlAttrs": { "lang": "en" }, "link": [ { "key": "i18n-xd", "rel": "alternate", "href": "http://localhost:3000/nuxt-context-extension", "hreflang": "x-default" }, { "key": "i18n-alt-en", "rel": "alternate", "href": "http://localhost:3000/nuxt-context-extension", "hreflang": "en" }, { "key": "i18n-alt-fr", "rel": "alternate", "href": "http://localhost:3000/fr/nuxt-context-extension", "hreflang": "fr" }, { "key": "i18n-alt-ja", "rel": "alternate", "href": "http://localhost:3000/ja/nuxt-context-extension", "hreflang": "ja" }, { "key": "i18n-alt-ja-JP", "rel": "alternate", "href": "http://localhost:3000/ja/nuxt-context-extension", "hreflang": "ja-JP" }, { "key": "i18n-alt-nl", "rel": "alternate", "href": "http://localhost:3000/nl/nuxt-context-extension", "hreflang": "nl" }, { "key": "i18n-alt-nl-NL", "rel": "alternate", "href": "http://localhost:3000/nl/nuxt-context-extension", "hreflang": "nl-NL" }, { "key": "i18n-alt-nl-BE", "rel": "alternate", "href": "http://localhost:3000/be/nuxt-context-extension", "hreflang": "nl-BE" }, { "key": "i18n-alt-kr", "rel": "alternate", "href": "http://localhost:3000/kr/nuxt-context-extension", "hreflang": "kr" }, { "key": "i18n-alt-kr-KO", "rel": "alternate", "href": "http://localhost:3000/kr/nuxt-context-extension", "hreflang": "kr-KO" }, { "key": "i18n-can", "rel": "canonical", "href": "http://localhost:3000/nuxt-context-extension" } ], "meta": [ { "key": "i18n-og-url", "property": "og:url", "content": "http://localhost:3000/nuxt-context-extension" }, { "key": "i18n-og", "property": "og:locale", "content": "en" }, { "key": "i18n-og-alt-fr", "property": "og:locale:alternate", "content": "fr" }, { "key": "i18n-og-alt-ja-JP", "property": "og:locale:alternate", "content": "ja_JP" }, { "key": "i18n-og-alt-nl-NL", "property": "og:locale:alternate", "content": "nl_NL" }, { "key": "i18n-og-alt-nl-BE", "property": "og:locale:alternate", "content": "nl_BE" }, { "key": "i18n-og-alt-kr-KO", "property": "og:locale:alternate", "content": "kr_KO" } ] }"`
136136
)
137137
})
138138

‎specs/fixtures/domain-ssg/app.vue‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<Html :lang="head.htmlAttrs.lang" :dir="head.htmlAttrs.dir">
33
<Head>
44
<Title>Test</Title>
5-
<template v-for="link in head.link" :key="link.hid">
6-
<Link :id="link.hid" :rel="link.rel" :href="link.href" :hreflang="link.hreflang" />
5+
<template v-for="link in head.link" :key="link.key">
6+
<Link :id="link.key" :rel="link.rel" :href="link.href" :hreflang="link.hreflang" />
77
</template>
8-
<template v-for="meta in head.meta" :key="meta.hid">
9-
<Meta :id="meta.hid" :property="meta.property" :content="meta.content" />
8+
<template v-for="meta in head.meta" :key="meta.key">
9+
<Meta :id="meta.key" :property="meta.property" :content="meta.content" />
1010
</template>
1111
</Head>
1212
<Body>

‎specs/helper.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export async function renderPage(path = '/', options?: BrowserContextOptions) {
7676
const browser = await getBrowser()
7777
const page = await browser.newPage(options)
7878

79-
page.setDefaultNavigationTimeout(5 * 1000)
79+
page.setDefaultNavigationTimeout(process.env.CI ? 30 * 1000 : 5 * 1000)
8080

8181
const _locator = page.locator.bind(page)
8282
page.locator = (selector, options) => {

‎src/runtime/composables/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export function useLocaleHead({
8080
dir = true,
8181
lang = true,
8282
seo = true,
83-
key = 'hid'
83+
key = 'key'
8484
}: I18nHeadOptions = {}): Ref<I18nHeadMetaInfo> {
8585
const common = useComposableContext()
8686
return _useLocaleHead(common, { dir, lang, seo, key })

‎src/runtime/routing/head.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function createHeadContext(
5353
*/
5454
export function localeHead(
5555
ctx: ComposableContext,
56-
{ dir = true, lang = true, seo = true, key = 'hid' }: I18nHeadOptions
56+
{ dir = true, lang = true, seo = true, key = 'key' }: I18nHeadOptions
5757
): I18nHeadMetaInfo {
5858
return _localeHead(createHeadContext(ctx, { dir, lang, seo, key }))
5959
}

‎src/types.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ export interface I18nHeadOptions {
312312
seo?: boolean | SeoAttributesOptions
313313
/**
314314
* Identifier attribute of `<meta>` tag
315-
* @default 'hid'
315+
* @default 'key'
316316
*/
317317
key?: string
318318
}

0 commit comments

Comments
 (0)