Given basic _layout.svelte component
<script context="module">
import { darkMode } from "../store";
import { isLoading, waitLocale } from 'svelte-i18n';
export async function preload(page) {
darkMode.set(getCookie("isDark") || window.matchMedia("(prefers-color-scheme: dark)").matches);
return waitLocale();
}
</script>
I have two questions:
- why preload in layout doesn't run even if I just add the only console.log inside
- how to add class '.mode-dark' to the
documenton the server-side? document is undefined