File tree Expand file tree Collapse file tree 4 files changed +39
-0
lines changed Expand file tree Collapse file tree 4 files changed +39
-0
lines changed File renamed without changes.
Original file line number Diff line number Diff line change 1+ "use client" ;
2+
3+ import { useEffect } from "react" ;
4+ import { useTheme } from "next-themes" ;
5+
6+ export default function Favicon ( ) {
7+ const { resolvedTheme } = useTheme ( ) ;
8+
9+ useEffect ( ( ) => {
10+ const favicon =
11+ document . querySelector ( "link[rel*='icon']" ) ||
12+ document . createElement ( "link" ) ;
13+ favicon . setAttribute ( "rel" , "icon" ) ;
14+
15+ if ( resolvedTheme === "dark" ) {
16+ favicon . setAttribute ( "href" , "/icon-dark.svg" ) ;
17+ } else {
18+ favicon . setAttribute ( "href" , "/icon-light.svg" ) ;
19+ }
20+
21+ document . head . appendChild ( favicon ) ;
22+ } , [ resolvedTheme ] ) ;
23+
24+ return null ;
25+ }
Original file line number Diff line number Diff line change 22
33import { HeroUIProvider , ToastProvider } from "@heroui/react" ;
44import { ThemeProvider as NextThemesProvider } from "next-themes" ;
5+ import Favicon from "./favicon" ;
56
67type Props = {
78 children : React . ReactNode ;
@@ -22,6 +23,7 @@ export default function Providers({ children }: Props) {
2223 } }
2324 />
2425 < NextThemesProvider attribute = "class" defaultTheme = "system" enableSystem >
26+ < Favicon />
2527 { children }
2628 </ NextThemesProvider >
2729 </ HeroUIProvider >
You can’t perform that action at this time.
0 commit comments