blob: 61ab5f350e9c8f8ea0a1e82eaa12740c39def680 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
<script lang="ts">
import { blogStorage } from '$/lib/storage';
import { page } from '$app/state';
import { onDestroy, onMount, type Snippet } from 'svelte';
const {
children,
}: {
children: Snippet;
} = $props();
onMount(() => {
const theme =
page.url.searchParams.get('theme') ?? blogStorage.getItem('theme');
if (theme) {
blogStorage.setItem('theme', theme);
document.documentElement.setAttribute('data-blog-theme', theme);
page.url.searchParams.delete('theme');
}
});
onDestroy(() => {
if (typeof document !== 'undefined')
document.documentElement.removeAttribute('data-blog-theme');
});
</script>
{@render children()}
|