feat: 사이트 테마 SSR 적용

This commit is contained in:
2025-03-21 09:56:25 +09:00
parent 580d449f3e
commit 699eadb399
2 changed files with 6 additions and 3 deletions
+5 -2
View File
@@ -1,10 +1,13 @@
import "./styles/base.css";
import "./styles/components.css";
import { AppProvider } from "./providers";
import { cookies } from "next/headers";
const App = async ({ children }: Readonly<{ children: React.ReactNode }>) => {
const theme = (await cookies()).get("site-theme-key");
const App = ({ children }: Readonly<{ children: React.ReactNode }>) => {
return (
<html lang="ko">
<html lang="ko" data-theme={theme?.value}>
<body>
<AppProvider>{children}</AppProvider>
</body>
@@ -26,7 +26,7 @@ export function Header({ viewOnly }: { viewOnly?: boolean }) {
select: (data) => {
if (data.siteSkn) {
const siteSkin = data.siteSkn.toLowerCase();
setCookie("data-theme", siteSkin);
setCookie("site-theme-key", siteSkin);
document.documentElement.setAttribute("data-theme", siteSkin);
}
return data;