diff --git a/src/app.html b/src/app.html index 9a0f5b64..ab56033b 100644 --- a/src/app.html +++ b/src/app.html @@ -5,6 +5,12 @@ %sveltekit.head% +
{ +export const handle: Handle = async ({ event, resolve }) => { event.locals.supabase = createSupabaseServerClient({ supabaseUrl: PUBLIC_SUPABASE_URL, supabaseKey: PUBLIC_SUPABASE_ANON_KEY, @@ -38,18 +37,3 @@ const setSession: Handle = async ({ event, resolve }) => { }, }) } - -const insertTheme: Handle = async ({ event, resolve }) => { - const theme = event.cookies.get("theme") - - return await resolve(event, { - transformPageChunk: ({ html }) => { - if (theme) { - html = html.replace('data-theme="default"', `data-theme="${theme}"`) - } - return html - }, - }) -} - -export const handle = sequence(setSession, insertTheme) diff --git a/src/routes/(admin)/account/(menu)/theme.svelte b/src/routes/(admin)/account/(menu)/theme.svelte index c0601909..48d0033e 100644 --- a/src/routes/(admin)/account/(menu)/theme.svelte +++ b/src/routes/(admin)/account/(menu)/theme.svelte @@ -10,7 +10,11 @@ ? "dark" : "default" document.querySelector("html")?.setAttribute("data-theme", theme) - document.cookie = `theme=${theme}; expires=Thu, 1 Dec 2050 12:00:00 UTC` + if (theme !== "default") { + localStorage.setItem("ui_theme", theme) + } else { + localStorage.removeItem("ui_theme") + } }