diff --git a/e2e/docs/.vuepress/config.ts b/e2e/docs/.vuepress/config.ts index 8460c8ddff..b8a3775978 100644 --- a/e2e/docs/.vuepress/config.ts +++ b/e2e/docs/.vuepress/config.ts @@ -7,20 +7,31 @@ import { e2eTheme } from './theme/node/e2eTheme.js' export default defineUserConfig({ base: '/', - head: [], + head: [ + ['meta', { name: 'foo', content: 'foo' }], + ['meta', { name: 'bar', content: 'bar' }], + ['meta', { name: 'baz', content: 'baz' }], + ], locales: { '/': { lang: 'en-US', title: 'VuePress E2E', description: 'VuePress E2E Test Site', - head: [], + head: [ + ['meta', { name: 'foo-en', content: 'foo-en' }], + ['meta', { name: 'bar', content: 'foobar' }], + ['meta', { name: 'baz', content: 'foobar baz' }], + ], }, '/zh/': { lang: 'zh-CN', title: 'VuePress E2E', description: 'VuePress E2E 测试站点', - head: [], + head: [ + ['meta', { name: 'foo-zh', content: 'foo-zh' }], + ['meta', { name: 'bar', content: 'foobar zh' }], + ], }, }, diff --git a/e2e/docs/.vuepress/public/favicon.ico b/e2e/docs/.vuepress/public/favicon.ico new file mode 100644 index 0000000000..07ff17f34b Binary files /dev/null and b/e2e/docs/.vuepress/public/favicon.ico differ diff --git a/e2e/docs/.vuepress/public/logo.png b/e2e/docs/.vuepress/public/logo.png new file mode 100644 index 0000000000..ac6beaff06 Binary files /dev/null and b/e2e/docs/.vuepress/public/logo.png differ diff --git a/e2e/tests/site-data.cy.ts b/e2e/tests/site-data.cy.ts index f000b7d844..cca6f83646 100644 --- a/e2e/tests/site-data.cy.ts +++ b/e2e/tests/site-data.cy.ts @@ -22,7 +22,18 @@ describe('siteData', () => { }) it('head', () => { - // TODO + cy.get('head meta[name="foo"]') + .should('have.length', 1) + .should('have.attr', 'content', 'foo') + cy.get('head meta[name="bar"]') + .should('have.length', 1) + .should('have.attr', 'content', 'foobar') + cy.get('head meta[name="baz"]') + .should('have.length', 1) + .should('have.attr', 'content', 'foobar baz') + cy.get('head meta[name="foo-en"]') + .should('have.length', 1) + .should('have.attr', 'content', 'foo-en') }) }) @@ -49,7 +60,18 @@ describe('siteData', () => { }) it('head', () => { - // TODO + cy.get('head meta[name="foo"]') + .should('have.length', 1) + .should('have.attr', 'content', 'foo') + cy.get('head meta[name="bar"]') + .should('have.length', 1) + .should('have.attr', 'content', 'foobar zh') + cy.get('head meta[name="baz"]') + .should('have.length', 1) + .should('have.attr', 'content', 'baz') + cy.get('head meta[name="foo-zh"]') + .should('have.length', 1) + .should('have.attr', 'content', 'foo-zh') }) }) }) diff --git a/packages/client/src/resolvers.ts b/packages/client/src/resolvers.ts index f8c70f3836..7ada2e9ec1 100644 --- a/packages/client/src/resolvers.ts +++ b/packages/client/src/resolvers.ts @@ -139,5 +139,11 @@ export const resolvers = reactive({ ): SiteLocaleData => ({ ...site, ...site.locales[routeLocale], + head: [ + // when merging head, the locales head should be placed before root head + // to get higher priority + ...(site.locales[routeLocale]?.head ?? []), + ...(site.head ?? []), + ], }), })