Skip to content

Commit

Permalink
Use dynamic base path for favicon images (#46719)
Browse files Browse the repository at this point in the history
  • Loading branch information
avatus authored Sep 18, 2024
1 parent 1efa0ae commit c86f46d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions web/packages/design/src/ThemeProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,18 @@ export function getPrefersDark(): boolean {
}

export function updateFavicon() {
let base = '/web/app/';
if (import.meta.env.MODE === 'development') {
base = '/app/';
}
const darkModePreferred = getPrefersDark();
const favicon = document.querySelector('link[rel="icon"]');

if (favicon instanceof HTMLLinkElement) {
if (darkModePreferred) {
favicon.href = '/app/favicon-dark.png';
favicon.href = base + 'favicon-dark.png';
} else {
favicon.href = '/app/favicon-light.png';
favicon.href = base + 'favicon-light.png';
}
}
}
Expand Down

0 comments on commit c86f46d

Please sign in to comment.