feat: support query theme bootstrap for embeds

This commit is contained in:
2026-04-02 20:41:18 +08:00
parent 83071a4b76
commit 6e55bc02b7
4 changed files with 87 additions and 9 deletions

View File

@@ -1,6 +1,25 @@
import type { Theme } from "./theme";
export type ResolvedTheme = "light" | "dark";
export type ThemeQueryMode = "light" | "dark" | "system";
export function parseThemeQuery(value: string | null | undefined): ThemeQueryMode | null {
if (!value) {
return null;
}
const normalized = value.toLowerCase();
if (normalized === "light" || normalized === "dark") {
return normalized;
}
if (normalized === "auto" || normalized === "system") {
return "system";
}
return null;
}
export function resolveStoredTheme(
theme: Theme,