aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/+layout.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/+layout.ts')
-rw-r--r--src/routes/+layout.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts
index 79a89d47..af4a6a5c 100644
--- a/src/routes/+layout.ts
+++ b/src/routes/+layout.ts
@@ -5,6 +5,9 @@ import { addIcon } from "iconify-icon";
import cookies from "js-cookie";
export const ssr = false;
+const expires = new Date();
+expires.setSeconds(expires.getSeconds() + 21000000);
+const opts = { path: "/", expires };
/** @type {import('@sveltejs/kit').Load} */
export const load = async ({ data }) => {
@@ -24,10 +27,8 @@ export const load = async ({ data }) => {
? "dark"
: "light";
- const expires = new Date();
- expires.setSeconds(expires.getSeconds() + 21000000);
+ cookies.set("theme", theme, opts);
- cookies.set("theme", theme, { path: "/", expires });
if (theme === "dark") setTimeout(() => themeStore.set(theme), 100);
}
}