diff --git a/components/nav/common.js b/components/nav/common.js index 0c6143fcd..d07382ada 100644 --- a/components/nav/common.js +++ b/components/nav/common.js @@ -121,8 +121,24 @@ export function NavSelect ({ sub: subName, className, size }) { export function NavNotifications ({ className }) { const hasNewNotes = useHasNewNotes() + useEffect(() => { + const setFavicon = (href) => { + // Remove all existing favicon link tags + const links = document.querySelectorAll('link[rel="icon"], link[rel="shortcut icon"]') + links.forEach(link => link.parentNode.removeChild(link)) + // Create new favicon link with cache-busting query + const link = document.createElement('link') + link.rel = 'shortcut icon' + link.type = 'image/png' + link.href = href + '?v=' + Date.now() + document.head.appendChild(link) + } + setFavicon(hasNewNotes ? '/favicon-notify.png' : '/favicon.png') + }, [hasNewNotes]) + return ( <> + {/* fallback for SSR, but will be replaced on client by useEffect */}