File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"use client"
22
33import * as React from "react"
4- import { ThemeProvider as NextThemesProvider } from "next-themes"
4+ import { ThemeProvider as NextThemesProvider , useTheme } from "next-themes"
5+
6+ function ThemeColorUpdater ( ) {
7+ const { resolvedTheme } = useTheme ( )
8+
9+ React . useEffect ( ( ) => {
10+ const metaThemeColor = document . querySelector ( 'meta[name="theme-color"]' )
11+ if ( metaThemeColor ) {
12+ metaThemeColor . setAttribute (
13+ 'content' ,
14+ resolvedTheme === 'dark' ? '#000000' : '#ffffff'
15+ )
16+ }
17+ } , [ resolvedTheme ] )
18+
19+ return null
20+ }
521
622export function ThemeProvider ( { children, ...props } : React . ComponentProps < typeof NextThemesProvider > ) {
7- return < NextThemesProvider { ...props } > { children } </ NextThemesProvider >
23+ return (
24+ < NextThemesProvider { ...props } >
25+ < ThemeColorUpdater />
26+ { children }
27+ </ NextThemesProvider >
28+ )
829}
You can’t perform that action at this time.
0 commit comments