blob: 65d3343326cd05e2aa203378750a5d08e5920a50 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import * as React from "react"
import { useTheme } from "next-themes"
import { META_THEME_COLORS } from "@/config/site"
export function useMetaColor() {
const { resolvedTheme } = useTheme()
const metaColor = React.useMemo(() => {
return resolvedTheme !== "dark"
? META_THEME_COLORS.light
: META_THEME_COLORS.dark
}, [resolvedTheme])
const setMetaColor = React.useCallback((color: string) => {
document
.querySelector('meta[name="theme-color"]')
?.setAttribute("content", color)
}, [])
return {
metaColor,
setMetaColor,
}
}
|