cabotia / cabotia.dev/ layouts/_default/baseof.html5d986b13949cef9204ed7c135e244bf8b81e3f9f
4.1 KB | 133 lines Raw
1
<!DOCTYPE html>
2
<html lang="{{ .Site.Language.Lang }}">
3
	<head>
4
		<meta charset="utf-8">
5
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6
		<meta name="description" content="{{ .Description | default (.Summary | plainify) }}">
7
		<meta name="color-scheme" content="light dark">
8

9
		<title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ .Title }} · {{ .Site.Params.brand }}{{ end }}</title>
10

11
		<link rel="icon" href="/favicon.ico" sizes="any">
12
		<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
13
		<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
14
		<link rel="apple-touch-icon" href="/apple-touch-icon.png">
15

16
		<script>
17
			(() => {
18
				try {
19
					const stored = localStorage.getItem('theme');
20
					const dark = stored
21
						? stored === 'dark'
22
						: window.matchMedia('(prefers-color-scheme: dark)').matches;
23
					document.documentElement.dataset.theme = dark ? 'dark' : 'light';
24
				} catch (error) {
25
					document.documentElement.dataset.theme = 'light';
26
				}
27
			})();
28
		</script>
29

30
		{{ $style := resources.Get "main.scss" | css.Sass | resources.Minify | resources.Fingerprint }}
31
		<link rel="stylesheet" href="{{ $style.RelPermalink }}">
32

33
		{{ range .AllTranslations }}
34
			<link rel="alternate" hreflang="{{ .Language.Lang }}" href="{{ .Permalink }}">
35
		{{ end }}
36

37
		{{ range .AlternativeOutputFormats -}}
38
			{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
39
		{{ end -}}
40

41
		{{ template "_internal/opengraph.html" . }}
42
	</head>
43

44
	<body>
45
		<header>
46
			<div class="logo">
47
				<a href="{{ .Site.Home.RelPermalink }}">
48
					<img class="logo-type" src="{{ (resources.Get "images/Cabotia.svg").RelPermalink }}" alt="{{ i18n "logo.alt" }}">
49
				</a>
50
			</div>
51

52
			<nav>
53
				<a href="{{ "/" | relLangURL }}">
54
					{{ i18n "nav.about" | safeHTML }}
55
				</a>
56
				<a href="{{ "work/" | relLangURL }}">
57
					{{ i18n "nav.work" | safeHTML }}
58
				</a>
59
				<a href="{{ "posts/" | relLangURL }}">
60
					{{ i18n "nav.blog" | safeHTML }}
61
				</a>
62
				<a href="mailto:contact@cabotia.dev">
63
					{{ i18n "nav.contact" | safeHTML }}
64
				</a>
65
			</nav>
66

67
			<div class="header-actions">
68
				{{ partial "language-switcher.html" . }}
69

70
				<button class="theme-toggle" type="button" aria-pressed="false" aria-label="{{ i18n "theme.to_dark" }}" data-label-dark="{{ i18n "theme.to_dark" }}" data-label-light="{{ i18n "theme.to_light" }}">
71
					<svg class="icon-sun" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
72
						<circle cx="12" cy="12" r="4"></circle>
73
						<path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"></path>
74
					</svg>
75
					<svg class="icon-moon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
76
						<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
77
					</svg>
78
				</button>
79
			</div>
80
		</header>
81

82
		<main>
83
			{{ block "main" . }}{{ end }}
84
		</main>
85

86
		<footer>
87
			<div>
88
				&copy; {{ time.Now.Year }} · cabotiá
89
			</div>
90

91
			<div class="links">
92
				<a href="https://git.sr.ht/~porcellis/cabotia.dev">
93
					{{ i18n "footer.code" | safeHTML }}
94
				</a>,&nbsp;
95

96
				<a href="https://git.sr.ht/~porcellis/cabotia.dev/tree/main/item/LICENSE">
97
					{{ i18n "footer.license" | safeHTML }}
98
				</a>
99
			</div>
100

101
			<div class="fine-line">
102
				{{ i18n "footer.fine_line" | safeHTML }}
103
			</div>
104
		</footer>
105

106
		<script>
107
			(() => {
108
				const root = document.documentElement;
109
				const toggle = document.querySelector('.theme-toggle');
110
				if (!toggle) return;
111

112
				const labelDark = toggle.dataset.labelDark;
113
				const labelLight = toggle.dataset.labelLight;
114

115
				const sync = () => {
116
					const dark = root.dataset.theme === 'dark';
117
					toggle.setAttribute('aria-pressed', String(dark));
118
					toggle.setAttribute('aria-label', dark ? labelLight : labelDark);
119
				};
120

121
				toggle.addEventListener('click', () => {
122
					root.dataset.theme = root.dataset.theme === 'dark' ? 'light' : 'dark';
123
					try {
124
						localStorage.setItem('theme', root.dataset.theme);
125
					} catch (error) {}
126
					sync();
127
				});
128

129
				sync();
130
			})();
131
		</script>
132
	</body>
133
</html>