Migrate from old project

This commit is contained in:
2025-04-02 18:25:10 +02:00
parent ce90c48825
commit 4566f2559f
55 changed files with 2774 additions and 233 deletions

View File

@@ -0,0 +1,18 @@
"use server";
import {cookies} from "next/headers";
// ✅ Get theme from cookies OR detect system preference
export async function getInitialTheme(): Promise<"dark" | "light"> {
const themeCookie = (await cookies()).get("theme")?.value;
if (themeCookie === "dark" || themeCookie === "light") {
return themeCookie;
}
// Detect system preference
const prefersDarkMode =
typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches;
return prefersDarkMode ? "dark" : "light";
}