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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package page
templ Base(name string) {
<!DOCTYPE html>
<html
lang="en"
class="h-full"
x-data="theme"
x-init="init()"
:data-theme="isDark ? 'dark' : 'light'"
>
<head>
<meta charset="UTF-8"/>
<title>{ name }</title>
<link rel="icon" href="/favicon.ico"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="language" content="English"/>
<script src="https://unpkg.com/[email protected]" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
<script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>
<script src="https://unpkg.com/[email protected]"></script>
<link rel="stylesheet" href="/dist/styles.min.css"/>
<style>[x-cloak] { display: none !important; }</style>
<script>
document.addEventListener('alpine:init', () => {
Alpine.data('theme', () => ({
isDark: localStorage.getItem('theme') === 'dark',
init() {
if (localStorage.getItem('theme') === null) {
this.isDark = window.matchMedia('(prefers-color-scheme: dark)').matches
localStorage.setItem('theme', this.isDark ? 'dark' : 'light')
}
},
toggle() {
this.isDark = !this.isDark
localStorage.setItem('theme', this.isDark ? 'dark' : 'light')
}
}))
})
</script>
</head>
<body class="h-full cursor-default bg-base-200" hx-sync="this:queue all">
{ children... }
</body>
</html>
}
|