From 662d77531236e81b946138a7f4dc183f4be7bca2 Mon Sep 17 00:00:00 2001 From: techfg Date: Sat, 30 Nov 2024 10:59:16 -0800 Subject: [PATCH] chore: remove rel shortcut from favicon --- .changeset/lazy-rats-decide.md | 5 +++++ packages/starlight/__tests__/basics/head.test.ts | 3 ++- packages/starlight/components/Head.astro | 3 ++- packages/starlight/utils/head.ts | 7 ++++++- 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .changeset/lazy-rats-decide.md diff --git a/.changeset/lazy-rats-decide.md b/.changeset/lazy-rats-decide.md new file mode 100644 index 00000000000..2738f73bb57 --- /dev/null +++ b/.changeset/lazy-rats-decide.md @@ -0,0 +1,5 @@ +--- +'@astrojs/starlight': patch +--- + +Remove 'shortcut' from favicon rel attribute diff --git a/packages/starlight/__tests__/basics/head.test.ts b/packages/starlight/__tests__/basics/head.test.ts index 3824d1ccfd9..463f1d2f5de 100644 --- a/packages/starlight/__tests__/basics/head.test.ts +++ b/packages/starlight/__tests__/basics/head.test.ts @@ -91,9 +91,10 @@ describe('createHead', () => { const defaultFavicon = { tag: 'link', attrs: { - rel: 'shortcut icon', + rel: 'icon', href: '/favicon.svg', type: 'image/svg+xml', + 'data-favicon': 'default', }, } as const; diff --git a/packages/starlight/components/Head.astro b/packages/starlight/components/Head.astro index 3a66e7c5253..c9cdd746f8a 100644 --- a/packages/starlight/components/Head.astro +++ b/packages/starlight/components/Head.astro @@ -32,9 +32,10 @@ const headDefaults: z.input> = [ { tag: 'link', attrs: { - rel: 'shortcut icon', + rel: 'icon', href: fileWithBase(config.favicon.href), type: config.favicon.type, + 'data-favicon': 'default', }, }, // OpenGraph Tags diff --git a/packages/starlight/utils/head.ts b/packages/starlight/utils/head.ts index 05be81f2bae..46f98206891 100644 --- a/packages/starlight/utils/head.ts +++ b/packages/starlight/utils/head.ts @@ -89,7 +89,12 @@ function getImportance(entry: HeadConfig[number]) { // The default favicon should be below any extra icons that the user may have set // because if several icons are equally appropriate, the last one is used and we // want to use the SVG icon when supported. - if (entry.tag === 'link' && 'rel' in entry.attrs && entry.attrs.rel === 'shortcut icon') { + if ( + entry.tag === 'link' && + 'rel' in entry.attrs && + entry.attrs.rel === 'icon' && + entry.attrs['data-favicon'] === 'default' + ) { return 70; } return 80;