diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-03-26 00:37:41 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-03-26 00:37:41 +0000 |
| commit | e0dfb55c5457aec489fc084c4567e791b4c65eb1 (patch) | |
| tree | 68543a65d88f5afb3a0202925804103daa91bc6f /hooks/use-meta-color.ts | |
3/25 까지의 대표님 작업사항
Diffstat (limited to 'hooks/use-meta-color.ts')
| -rw-r--r-- | hooks/use-meta-color.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/hooks/use-meta-color.ts b/hooks/use-meta-color.ts new file mode 100644 index 00000000..65d33433 --- /dev/null +++ b/hooks/use-meta-color.ts @@ -0,0 +1,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, + } +}
\ No newline at end of file |
