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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
{{$path := .OriginalReq.URL.Path -}}
{{$file := printf "%s.md" (trimSuffix "/" $path) -}}
{{if not (fileExists $file)}}{{httpError 404}}{{end -}}
{{/* readFile, not include: include evaluates the .md as a template, so a
     document quoting this file's own source recurses until caddy OOMs. */ -}}
{{$doc := readFile $file | splitFrontMatter -}}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light dark">
<title>{{default (trimSuffix ".md" $file) $doc.Meta.title}} — kejadlen.dev</title>
{{with $doc.Meta.description}}<meta name="description" content="{{.}}">
{{end}}<script>try{var t=localStorage.getItem("theme");if(t)document.documentElement.dataset.theme=t}catch(e){}</script>
<style>
/* alphabaster — palette from kejadlen/dotfiles (.config/ghostty/config) */

/* light-dark() reads color-scheme, so data-theme below is all the switch sets. */
:root {
	color-scheme: light dark;
	--bg: light-dark(#F0F0E4, #121218);
	--fg: light-dark(#121218, #F0F0E4);
	--muted: light-dark(#63635C, #888888);
	--border: light-dark(#C7C7B8, #44475A);
	--lavender: light-dark(#6B4CA8, #C4AAEA);
	--lavender-bright: light-dark(#513787, #D0BCF0);
	--cyan: light-dark(#1F6B7A, #A2D6E0);
	--green: light-dark(#28702C, #7BC275);
	--red: light-dark(#B3261E, #E97C7C);
	--code-bg: light-dark(#E4E4D6, #282A36);
	--selection-bg: light-dark(#C6D0F5, #626880);
	--selection-fg: light-dark(#303446, #c6d0f5);
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

::selection { background: var(--selection-bg); color: var(--selection-fg); }

a:focus-visible, button:focus-visible { outline: 2px solid var(--cyan); }

#theme {
	position: fixed;
	top: 1rem;
	right: 1rem;
	width: 2.25rem;
	height: 2.25rem;
	background: var(--code-bg);
	color: var(--fg);
	border: 1px solid var(--border);
	border-radius: 50%;
	font-size: 1rem;
	line-height: 1;
	cursor: pointer;
}

#theme:hover { border-color: var(--lavender); }

@media print { #theme { display: none; } }

body {
	margin: 0 auto;
	padding: 2rem 1rem 4rem;
	max-width: 44rem;
	background: var(--bg);
	color: var(--fg);
	font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* Narrow viewports have no side margin for the button to sit in. */
@media (max-width: 50rem) { body { padding-top: 4rem; } }

a { color: var(--lavender); }
a:hover { color: var(--lavender-bright); }

h1, h2, h3, h4, h5, h6 { color: var(--cyan); line-height: 1.25; margin: 1.5em 0 0.5em; }
h1:first-child { margin-top: 0; }

blockquote {
	border-left: 3px solid var(--border);
	margin-left: 0;
	padding-left: 1rem;
	color: var(--muted);
}

code, pre, kbd { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9em; }

code {
	background: var(--code-bg);
	color: var(--lavender);
	padding: 0.15em 0.35em;
	border-radius: 4px;
}

pre {
	background: var(--code-bg);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 1rem;
	overflow-x: auto;
	line-height: 1.5;
}

pre code { background: none; padding: 0; color: inherit; }

hr { border: 0; border-top: 1px solid var(--border); }

table { border-collapse: collapse; }
th, td { border: 1px solid var(--border); padding: 0.25rem 0.75rem; }

img { max-width: 100%; }

ul { padding-left: 1.5rem; }

/*
 * chroma — alphabaster: only comments, strings and constants, and
 * definitions get color; keywords and operators stay default fg.
 */
.chroma .c, .chroma .c1, .chroma .c2, .chroma .ch, .chroma .cm, .chroma .cp, .chroma .cs {
	color: var(--muted);
}

.chroma .s, .chroma .s1, .chroma .s2, .chroma .sa, .chroma .sb, .chroma .sc,
.chroma .sd, .chroma .se, .chroma .sf, .chroma .sh, .chroma .si, .chroma .sj,
.chroma .sr, .chroma .ss, .chroma .sx,
.chroma .m, .chroma .mb, .chroma .mf, .chroma .mh, .chroma .mi, .chroma .mo, .chroma .mx,
.chroma .kc, .chroma .no {
	color: var(--lavender);
}

.chroma .fm, .chroma .nc, .chroma .ne, .chroma .nf, .chroma .nl, .chroma .nn {
	color: var(--cyan);
}

.chroma .gi { color: var(--green); }
.chroma .gd { color: var(--red); }
.chroma .err { color: var(--red); }
.chroma .ge { font-style: italic; }
.chroma .gs { font-weight: bold; }
</style>
</head>
<body>
<button id="theme" hidden></button>
<article>
{{$doc.Body | markdown}}
</article>
<script>
(function () {
	var root = document.documentElement;
	var btn = document.getElementById("theme");
	var system = matchMedia("(prefers-color-scheme: dark)");

	function effective() {
		return root.dataset.theme || (system.matches ? "dark" : "light");
	}

	function label() {
		var next = effective() === "dark" ? "light" : "dark";
		btn.textContent = next === "dark" ? "☽" : "☀";
		btn.setAttribute("aria-label", "Switch to " + next + " theme");
	}

	btn.addEventListener("click", function () {
		var next = effective() === "dark" ? "light" : "dark";
		// Matching the system again drops back to following it.
		if (next === (system.matches ? "dark" : "light")) {
			delete root.dataset.theme;
			try { localStorage.removeItem("theme"); } catch (e) {}
		} else {
			root.dataset.theme = next;
			try { localStorage.setItem("theme", next); } catch (e) {}
		}
		label();
	});

	system.addEventListener("change", label);
	label();
	btn.hidden = false;
})();
</script>
</body>
</html>