Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove rel shortcut from favicon #2646

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lazy-rats-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/starlight': patch
---

Remove 'shortcut' from favicon rel attribute
3 changes: 2 additions & 1 deletion packages/starlight/__tests__/basics/head.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR @techfg!

Could you explain why the data-favicon attribute was added in this PR? It’s not mentioned in the PR description and I don’t believe it’s a web standard.

},
} as const;

Expand Down
3 changes: 2 additions & 1 deletion packages/starlight/components/Head.astro
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ const headDefaults: z.input<ReturnType<typeof HeadConfigSchema>> = [
{
tag: 'link',
attrs: {
rel: 'shortcut icon',
rel: 'icon',
href: fileWithBase(config.favicon.href),
type: config.favicon.type,
'data-favicon': 'default',
},
},
// OpenGraph Tags
Expand Down
7 changes: 6 additions & 1 deletion packages/starlight/utils/head.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down