Files
myeasycms-v2/apps/web/lib/root-theme.ts
2025-01-07 20:34:40 +08:00

17 lines
439 B
TypeScript

import { cookies } from 'next/headers';
type Theme = 'light' | 'dark' | 'system';
/**
* @name getRootTheme
* @description Get the root theme from the cookies or default theme.
* @returns The root theme.
*/
export async function getRootTheme() {
const cookiesStore = await cookies();
const themeCookie = cookiesStore.get('theme')?.value as Theme;
return themeCookie ?? process.env.NEXT_PUBLIC_DEFAULT_THEME_MODE ?? 'light';
}