@bendyline/gezel-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,619 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/handboek-export.ts
4
+ import { existsSync } from "fs";
5
+ import { cp, mkdir, writeFile } from "fs/promises";
6
+ import { join, resolve } from "path";
7
+ import { CatalogService } from "@bendyline/gezel-catalog";
8
+ import {
9
+ createHandboekEngine,
10
+ findHandboekContent,
11
+ siteDeviceInfo
12
+ } from "@bendyline/gezel-service/handboek";
13
+ import { generateExternalHtml, markdownDocToPlainHtml } from "@bendyline/squisq-formats/html";
14
+ import { PLAYER_BUNDLE } from "@bendyline/squisq-react/standalone-source";
15
+ import { markdownToDoc } from "@bendyline/squisq/doc";
16
+ import { parseMarkdown } from "@bendyline/squisq/markdown";
17
+
18
+ // src/handboek-site-css.ts
19
+ var BASELINE_CSS = `:root {
20
+ --hb-canvas: #eae5d6;
21
+ --hb-panel: #f3eddf;
22
+ --hb-reading: #f1e9e1;
23
+ --hb-inset: #ddd3bd;
24
+ --hb-ink: #1c1c1c;
25
+ --hb-ink-warm: #2a2520;
26
+ --hb-ink-muted: #5a4f42;
27
+ --hb-ink-quiet: #8b7e6b;
28
+ --hb-sage: #667f62;
29
+ --hb-sage-forest: #3d4d3a;
30
+ --hb-cream-ink: #f3ede0;
31
+ --hb-accent: #b0724c;
32
+ --hb-accent-hover: #996142;
33
+ --hb-border: rgba(127, 127, 127, 0.25);
34
+ --hb-radius-sm: 4px;
35
+ --hb-radius-md: 6px;
36
+ --hb-radius-lg: 10px;
37
+ --hb-font-display: 'PT Serif', Georgia, 'Times New Roman', serif;
38
+ --hb-font-ui: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
39
+ --hb-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
40
+ --hb-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 6px 18px rgba(0, 0, 0, 0.06);
41
+ --hb-measure: 42rem;
42
+ }
43
+
44
+ @media (prefers-color-scheme: dark) {
45
+ :root {
46
+ --hb-canvas: #141517;
47
+ --hb-panel: #1c1d20;
48
+ --hb-reading: #1a1b1e;
49
+ --hb-inset: #1f2124;
50
+ --hb-ink: #f0f0f0;
51
+ --hb-ink-warm: #ececec;
52
+ --hb-ink-muted: #999999;
53
+ --hb-ink-quiet: #808080;
54
+ --hb-sage: #4d6149;
55
+ --hb-accent: #c0875d;
56
+ --hb-accent-hover: #d5a07a;
57
+ --hb-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.36);
58
+ }
59
+ }
60
+
61
+ *, *::before, *::after { box-sizing: border-box; }
62
+
63
+ body.hb {
64
+ margin: 0;
65
+ background: var(--hb-canvas);
66
+ color: var(--hb-ink);
67
+ font-family: var(--hb-font-ui);
68
+ font-size: 1rem;
69
+ line-height: 1.6;
70
+ -webkit-font-smoothing: antialiased;
71
+ }
72
+
73
+ .hb a { color: var(--hb-accent); text-decoration: none; }
74
+ .hb a:hover { color: var(--hb-accent-hover); text-decoration: underline; }
75
+ .hb a:focus-visible {
76
+ outline: 2px solid var(--hb-accent);
77
+ outline-offset: 2px;
78
+ border-radius: var(--hb-radius-sm);
79
+ }
80
+
81
+ /* Masthead \u2014 sage is a place, never a control. */
82
+ .hb-masthead {
83
+ display: flex;
84
+ flex-wrap: wrap;
85
+ align-items: baseline;
86
+ gap: 0.5rem 1.5rem;
87
+ padding: 0.85rem 1.5rem;
88
+ background: var(--hb-sage);
89
+ color: var(--hb-cream-ink);
90
+ }
91
+ .hb-brand {
92
+ font-family: var(--hb-font-display);
93
+ font-size: 1.15rem;
94
+ font-weight: 700;
95
+ }
96
+
97
+ /* The product wordmark, back out to the surrounding site. Lowercase italic
98
+ serif at PT Serif's natural 400 \u2014 the family ships only 400 and 700, so
99
+ anything between synthesizes a weight. Set apart from the Handboek title
100
+ by a hairline rule rather than by size. */
101
+ .hb-wordmark {
102
+ font-family: var(--hb-font-display);
103
+ font-style: italic;
104
+ font-weight: 400;
105
+ font-size: 1.15rem;
106
+ text-transform: lowercase;
107
+ padding-right: 0.6rem;
108
+ margin-right: 0.1rem;
109
+ border-right: 1px solid rgba(243, 237, 224, 0.35);
110
+ opacity: 0.9;
111
+ }
112
+ .hb-wordmark:hover { opacity: 1; }
113
+ .hb-masthead a, .hb-masthead a:hover { color: var(--hb-cream-ink); }
114
+ .hb-areanav { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.9rem; }
115
+ .hb-areanav a { opacity: 0.85; }
116
+ .hb-areanav a:hover, .hb-areanav a[aria-current='true'] { opacity: 1; }
117
+ .hb-areanav a[aria-current='true'] { text-decoration: underline; text-underline-offset: 4px; }
118
+
119
+ /* Three-column reading layout: nav, article, on-this-page.
120
+ The third column is reserved even on the ~300 generated catalog articles
121
+ that carry too few headings to warrant a list, so the article body holds
122
+ the same position as you click between pages instead of jumping. */
123
+ .hb-layout {
124
+ display: grid;
125
+ grid-template-columns: 15rem minmax(0, 1fr) 13rem;
126
+ gap: 2.5rem;
127
+ align-items: start;
128
+ max-width: 84rem;
129
+ margin: 0 auto;
130
+ padding: 2rem 1.5rem 4rem;
131
+ }
132
+
133
+ .hb-sidebar, .hb-onthispage { position: sticky; top: 1.5rem; font-size: 0.9rem; }
134
+ .hb-sidebar section { margin-bottom: 1.5rem; }
135
+ .hb-sidebar h2, .hb-onthispage h2 {
136
+ margin: 0 0 0.5rem;
137
+ font-family: var(--hb-font-ui);
138
+ font-size: 0.72rem;
139
+ font-weight: 600;
140
+ letter-spacing: 0.08em;
141
+ text-transform: uppercase;
142
+ color: var(--hb-ink-quiet);
143
+ }
144
+ .hb-sidebar h2 a { color: inherit; }
145
+ .hb-sidebar h2.hb-current { color: var(--hb-ink-warm); }
146
+ .hb-sidebar ul, .hb-onthispage ul { list-style: none; margin: 0; padding: 0; }
147
+ .hb-sidebar li { margin: 0.15rem 0; }
148
+ .hb-sidebar a, .hb-onthispage a { color: var(--hb-ink-muted); }
149
+ .hb-sidebar a:hover, .hb-onthispage a:hover { color: var(--hb-accent); }
150
+ .hb-sidebar a.hb-current {
151
+ color: var(--hb-accent);
152
+ font-weight: 600;
153
+ border-left: 2px solid var(--hb-accent);
154
+ margin-left: -0.6rem;
155
+ padding-left: 0.45rem;
156
+ }
157
+ .hb-onthispage li { margin: 0.2rem 0; }
158
+ .hb-onthispage .hb-h3 { padding-left: 0.75rem; font-size: 0.85rem; }
159
+ .hb-more { margin: 0.4rem 0 0; font-size: 0.85rem; }
160
+
161
+ .hb-breadcrumb { font-size: 0.85rem; color: var(--hb-ink-quiet); margin-bottom: 1rem; }
162
+ .hb-breadcrumb a { color: var(--hb-ink-muted); }
163
+ .hb-breadcrumb span { margin: 0 0.35rem; }
164
+
165
+ /* Article \u2014 the editorial register. Headings serif, everything else sans. */
166
+ .hb-article {
167
+ max-width: var(--hb-measure);
168
+ background: var(--hb-reading);
169
+ border: 1px solid var(--hb-border);
170
+ border-radius: var(--hb-radius-lg);
171
+ box-shadow: var(--hb-shadow);
172
+ padding: 2.5rem 2.75rem 3rem;
173
+ color: var(--hb-ink-warm);
174
+ }
175
+ .hb-article h1, .hb-article h2, .hb-article h3,
176
+ .hb-article h4, .hb-article h5, .hb-article h6 {
177
+ font-family: var(--hb-font-display);
178
+ font-weight: 700;
179
+ line-height: 1.25;
180
+ color: var(--hb-ink-warm);
181
+ margin: 2rem 0 0.75rem;
182
+ }
183
+ .hb-article a { font-family: var(--hb-font-ui); }
184
+ .hb-article h1 { font-size: 2rem; margin-top: 0; }
185
+ .hb-article h2 {
186
+ font-size: 1.4rem;
187
+ padding-bottom: 0.3rem;
188
+ border-bottom: 1px solid var(--hb-border);
189
+ }
190
+ .hb-article h3 { font-size: 1.1rem; }
191
+ .hb-article p, .hb-article li { font-size: 1rem; }
192
+ .hb-article p { margin: 0 0 1rem; }
193
+ .hb-article ul, .hb-article ol { margin: 0 0 1rem; padding-left: 1.35rem; }
194
+ .hb-article li { margin: 0.3rem 0; }
195
+ .hb-article li > p { margin: 0; }
196
+ .hb-article img { max-width: 100%; height: auto; border-radius: var(--hb-radius-md); }
197
+ .hb-article hr { border: 0; border-top: 1px solid var(--hb-border); margin: 2rem 0; }
198
+ .hb-article blockquote {
199
+ margin: 0 0 1rem;
200
+ padding: 0.25rem 0 0.25rem 1rem;
201
+ border-left: 3px solid var(--hb-accent);
202
+ color: var(--hb-ink-muted);
203
+ }
204
+ .hb-article code {
205
+ font-family: var(--hb-font-mono);
206
+ font-size: 0.875em;
207
+ background: var(--hb-inset);
208
+ border-radius: var(--hb-radius-sm);
209
+ padding: 0.1em 0.35em;
210
+ }
211
+ .hb-article pre {
212
+ background: var(--hb-inset);
213
+ border: 1px solid var(--hb-border);
214
+ border-radius: var(--hb-radius-md);
215
+ padding: 0.9rem 1.1rem;
216
+ overflow-x: auto;
217
+ margin: 0 0 1rem;
218
+ }
219
+ .hb-article pre code { background: none; padding: 0; font-size: 0.85rem; }
220
+
221
+ /* Wide content scrolls inside its own box; the page never scrolls sideways.
222
+ The scroll lives on a wrapper, not on the table itself: display:block
223
+ on a table makes it shrink-to-content and stop filling the column. */
224
+ .hb-table-scroll {
225
+ overflow-x: auto;
226
+ max-width: 100%;
227
+ margin: 0 0 1.25rem;
228
+ }
229
+ .hb-article table {
230
+ border-collapse: collapse;
231
+ width: 100%;
232
+ font-size: 0.9rem;
233
+ }
234
+ /* Prose cells wrap. Catalog tables pair a short name against a full sentence
235
+ of description, so white-space:nowrap would push the description off the
236
+ page and force a horizontal scroll to read every row. */
237
+ .hb-article th, .hb-article td {
238
+ border: 1px solid var(--hb-border);
239
+ padding: 0.45rem 0.7rem;
240
+ text-align: left;
241
+ vertical-align: top;
242
+ overflow-wrap: anywhere;
243
+ }
244
+ .hb-article th { background: var(--hb-inset); font-weight: 600; }
245
+ /* Keep the leading label column from collapsing to one word per line while
246
+ the description column takes the slack. */
247
+ .hb-article tbody td:first-child { min-width: 11rem; }
248
+
249
+ .hb-watch { max-width: var(--hb-measure); margin: 1.25rem 0 0; font-size: 0.9rem; }
250
+
251
+ /* Home */
252
+ .hb-home-main { max-width: 62rem; margin: 0 auto; padding: 3rem 1.5rem 4rem; }
253
+ .hb-hero { max-width: var(--hb-measure); margin-bottom: 3rem; }
254
+ .hb-hero h1 {
255
+ font-family: var(--hb-font-display);
256
+ font-size: 2.6rem;
257
+ line-height: 1.15;
258
+ margin: 0 0 1rem;
259
+ color: var(--hb-sage-forest);
260
+ }
261
+ @media (prefers-color-scheme: dark) {
262
+ .hb-hero h1 { color: var(--hb-ink-warm); }
263
+ }
264
+ .hb-lede { font-size: 1.15rem; line-height: 1.6; color: var(--hb-ink-muted); margin: 0; }
265
+
266
+ .hb-home h2 {
267
+ font-family: var(--hb-font-display);
268
+ font-size: 1.3rem;
269
+ margin: 0 0 0.75rem;
270
+ color: var(--hb-ink-warm);
271
+ }
272
+ .hb-home h2 a { color: inherit; }
273
+ .hb-home h2 a:hover { color: var(--hb-accent); }
274
+
275
+ .hb-cards { list-style: none; margin: 0 0 3rem; padding: 0; display: grid; gap: 0.75rem;
276
+ grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
277
+ .hb-cards a {
278
+ display: block;
279
+ height: 100%;
280
+ padding: 1rem 1.1rem;
281
+ background: var(--hb-panel);
282
+ border: 1px solid var(--hb-border);
283
+ border-radius: var(--hb-radius-lg);
284
+ box-shadow: var(--hb-shadow);
285
+ color: var(--hb-ink-warm);
286
+ text-decoration: none;
287
+ }
288
+ .hb-cards a:hover { border-color: var(--hb-accent); text-decoration: none; }
289
+ .hb-card-title { display: block; font-weight: 600; margin-bottom: 0.25rem; }
290
+ .hb-card-summary { display: block; font-size: 0.9rem; color: var(--hb-ink-muted); }
291
+
292
+ .hb-areas { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }
293
+ .hb-area-blurb { color: var(--hb-ink-muted); margin: 0 0 0.6rem; font-size: 0.95rem; }
294
+ .hb-arealist { list-style: none; margin: 0 0 0.5rem; padding: 0; font-size: 0.95rem; }
295
+ .hb-arealist li { margin: 0.2rem 0; }
296
+
297
+ .hb-footer {
298
+ border-top: 1px solid var(--hb-border);
299
+ padding: 1.5rem;
300
+ text-align: center;
301
+ font-size: 0.85rem;
302
+ color: var(--hb-ink-quiet);
303
+ }
304
+ .hb-footer p { margin: 0; }
305
+
306
+ @media (max-width: 68rem) {
307
+ .hb-layout { grid-template-columns: 13rem minmax(0, 1fr); }
308
+ .hb-onthispage { display: none; }
309
+ }
310
+ @media (max-width: 48rem) {
311
+ .hb-layout { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; padding: 1.25rem 1rem 3rem; }
312
+ .hb-sidebar { position: static; }
313
+ .hb-article { padding: 1.5rem 1.25rem 2rem; }
314
+ .hb-hero h1 { font-size: 2rem; }
315
+ }
316
+ `;
317
+
318
+ // src/handboek-export.ts
319
+ var NAV_INLINE_MAX = 40;
320
+ var AREA_BLURBS = {
321
+ conceptual: "What gezel is, who your crew are, and how the pieces fit together.",
322
+ "gezel-roles": "The roles a gezel can take, and what each one is good at.",
323
+ craftbooks: "Step-by-step recipes your crew can run \u2014 one per job.",
324
+ "project-types": "Ready-made project setups, each with a crew and a bench.",
325
+ technical: "Architecture, file layout, providers, security, and the CLI."
326
+ };
327
+ var START_HERE = ["welcome", "the-crew", "projects-and-threads", "craftbooks-overview"];
328
+ var WORDMARK = "gezel";
329
+ async function runHandboekExport(opts) {
330
+ const out = resolve(opts.out);
331
+ const css = opts.css ?? [];
332
+ const siteUrl = opts.siteUrl;
333
+ const contentDir = findHandboekContent();
334
+ if (!contentDir) {
335
+ throw new Error(
336
+ "no handboek content tree found \u2014 run from a gezel checkout or install, or set GEZEL_HANDBOEK_DIR"
337
+ );
338
+ }
339
+ const engine = createHandboekEngine({
340
+ catalog: new CatalogService(),
341
+ device: siteDeviceInfo,
342
+ contentDir
343
+ });
344
+ const toc = await engine.toc();
345
+ const areas = toc.areas.map((a) => ({ ...a, entries: a.entries.filter((e) => e.siteVisible !== false) })).filter((a) => a.entries.length > 0);
346
+ const entries = areas.flatMap((a) => a.entries);
347
+ const ids = new Set(entries.map((e) => e.id));
348
+ const byStem = /* @__PURE__ */ new Map();
349
+ for (const e of entries) {
350
+ const stem = e.id.split("/").pop();
351
+ if (stem && !byStem.has(stem)) byStem.set(stem, e.id);
352
+ }
353
+ await mkdir(join(out, "assets"), { recursive: true });
354
+ await writeFile(join(out, "assets", "squisq-player.js"), PLAYER_BUNDLE, "utf8");
355
+ const skipped = [];
356
+ let pages = 0;
357
+ for (const entry of entries) {
358
+ const article = await engine.article(entry.id, { mode: "site" });
359
+ if (!article) {
360
+ skipped.push(entry.id);
361
+ continue;
362
+ }
363
+ const depth = entry.id.split("/").length;
364
+ const markdown = rewriteSiteLinks(article.markdown, entry.id, ids, byStem);
365
+ const parsed = parseMarkdown(markdown);
366
+ const { html: body, headings } = withHeadingIds(
367
+ wrapTables(extractBody(markdownDocToPlainHtml(parsed, { title: article.title })))
368
+ );
369
+ const dir = join(out, ...entry.id.split("/"));
370
+ await mkdir(dir, { recursive: true });
371
+ await writeFile(
372
+ join(dir, "index.html"),
373
+ articlePage({ entry, body, headings, areas, depth, css, siteUrl }),
374
+ "utf8"
375
+ );
376
+ const doc = markdownToDoc(parsed, {
377
+ articleId: article.id,
378
+ defaultDuration: article.defaultDuration ?? 6
379
+ });
380
+ await writeFile(
381
+ join(dir, "watch.html"),
382
+ generateExternalHtml(doc, {
383
+ playerScriptPath: `${up(depth)}assets/squisq-player.js`,
384
+ mode: "slideshow",
385
+ title: article.title,
386
+ autoPlay: true,
387
+ captionStyle: "social"
388
+ }),
389
+ "utf8"
390
+ );
391
+ pages += 2;
392
+ }
393
+ await writeFile(join(out, "index.html"), landingPage(areas, css, siteUrl), "utf8");
394
+ pages += 1;
395
+ const assetsSrc = join(contentDir, "assets");
396
+ if (existsSync(assetsSrc)) {
397
+ await cp(assetsSrc, join(out, "assets"), { recursive: true });
398
+ }
399
+ await writeFile(join(out, "assets", "handboek.css"), BASELINE_CSS, "utf8");
400
+ return { out, pages, skipped };
401
+ }
402
+ function rewriteSiteLinks(markdown, pageId, ids, byStem) {
403
+ const prefix = up(pageId.split("/").length);
404
+ return markdown.replace(/\]\(([^()\s]+)\)/g, (whole, rawTarget) => {
405
+ if (/^[a-z][a-z0-9+.-]*:/i.test(rawTarget) || rawTarget.startsWith("//") || rawTarget.startsWith("#")) {
406
+ return whole;
407
+ }
408
+ const [path, suffix = ""] = splitLinkSuffix(rawTarget);
409
+ const candidate = path.replace(/\.md$/, "").replace(/^(\.\.?\/)+/, "");
410
+ if (candidate.startsWith("assets/")) {
411
+ return `](${prefix}${candidate}${suffix})`;
412
+ }
413
+ const target = ids.has(candidate) ? candidate : byStem.get(candidate.split("/").pop() ?? "");
414
+ if (!target) return whole;
415
+ return `](${prefix}${target}/${suffix})`;
416
+ });
417
+ }
418
+ function splitLinkSuffix(raw) {
419
+ const idx = raw.search(/[?#]/);
420
+ return idx === -1 ? [raw, ""] : [raw.slice(0, idx), raw.slice(idx)];
421
+ }
422
+ var up = (depth) => "../".repeat(depth);
423
+ var esc = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
424
+ function extractBody(page) {
425
+ const match = page.match(/<body[^>]*>([\s\S]*)<\/body>/i);
426
+ return (match?.[1] ?? page).trim();
427
+ }
428
+ function wrapTables(body) {
429
+ return body.replace(
430
+ /<table[\s>][\s\S]*?<\/table>/gi,
431
+ (table) => `<div class="hb-table-scroll">${table}</div>`
432
+ );
433
+ }
434
+ function slugify(text) {
435
+ return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "section";
436
+ }
437
+ function withHeadingIds(body) {
438
+ const headings = [];
439
+ const used = /* @__PURE__ */ new Map();
440
+ const html = body.replace(
441
+ /<h([23])(\s[^>]*)?>([\s\S]*?)<\/h\1>/gi,
442
+ (whole, lvl, attrs, inner) => {
443
+ if (attrs && /\sid=/i.test(attrs)) return whole;
444
+ const text = stripTags(inner).trim();
445
+ if (!text) return whole;
446
+ const base = slugify(text);
447
+ const seen = used.get(base) ?? 0;
448
+ used.set(base, seen + 1);
449
+ const id = seen === 0 ? base : `${base}-${seen + 1}`;
450
+ headings.push({ id, text, level: Number(lvl) });
451
+ return `<h${lvl}${attrs ?? ""} id="${esc(id)}">${inner}</h${lvl}>`;
452
+ }
453
+ );
454
+ return { html, headings };
455
+ }
456
+ function stripTags(html) {
457
+ return html.replace(/<[^>]*>/g, "").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/\s+/g, " ");
458
+ }
459
+ function resolveCssHref(href, depth) {
460
+ if (/^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//") || href.startsWith("/")) {
461
+ return href;
462
+ }
463
+ return `${up(depth)}${href}`;
464
+ }
465
+ function cssLinks(css, depth) {
466
+ return [`${up(depth)}assets/handboek.css`, ...css.map((h) => resolveCssHref(h, depth))].map((href) => `<link rel="stylesheet" href="${esc(href)}">`).join("\n");
467
+ }
468
+ function head(title, css, depth, description) {
469
+ return `<!DOCTYPE html>
470
+ <html lang="en">
471
+ <head>
472
+ <meta charset="UTF-8">
473
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
474
+ <title>${esc(title)}</title>${description ? `
475
+ <meta name="description" content="${esc(description)}">` : ""}
476
+ ${cssLinks(css, depth)}
477
+ </head>`;
478
+ }
479
+ function masthead(areas, depth, siteUrl, currentArea) {
480
+ const links = areas.map((a) => {
481
+ const target = areaLanding(a);
482
+ const current = a.area === currentArea ? ' aria-current="true"' : "";
483
+ return `<a${current} href="${up(depth)}${esc(target)}/">${esc(a.title)}</a>`;
484
+ }).join("\n");
485
+ const wordmark = siteUrl ? `<a class="hb-wordmark" href="${esc(siteUrl)}">${WORDMARK}</a>
486
+ ` : "";
487
+ return `<header class="hb-masthead">
488
+ ${wordmark}<a class="hb-brand" href="${up(depth)}">Gezel Handboek</a>
489
+ <nav class="hb-areanav">
490
+ ${links}
491
+ </nav>
492
+ </header>`;
493
+ }
494
+ function areaLanding(area) {
495
+ const index = area.entries.find((e) => e.id.endsWith("-index") || e.id.endsWith("-overview"));
496
+ return (index ?? area.entries[0])?.id ?? "";
497
+ }
498
+ function sidebar(areas, entry, depth) {
499
+ const sections = areas.map((area) => {
500
+ const isCurrent = area.area === entry.area;
501
+ const items = isCurrent && area.entries.length <= NAV_INLINE_MAX ? area.entries : isCurrent ? dedupeById([...area.entries.filter((e) => e.id === areaLanding(area)), entry]) : [];
502
+ const list = items.length ? `<ul>
503
+ ${items.map((e) => {
504
+ const current = e.id === entry.id ? ' class="hb-current" aria-current="page"' : "";
505
+ return `<li><a${current} href="${up(depth)}${esc(e.id)}/">${esc(e.title)}</a></li>`;
506
+ }).join("\n")}
507
+ </ul>` : "";
508
+ const more = isCurrent && area.entries.length > NAV_INLINE_MAX ? `<p class="hb-more"><a href="${up(depth)}${esc(areaLanding(area))}/">All ${area.entries.length} ${esc(area.title.toLowerCase())}</a></p>` : "";
509
+ const heading = isCurrent ? `<h2 class="hb-current">${esc(area.title)}</h2>` : `<h2><a href="${up(depth)}${esc(areaLanding(area))}/">${esc(area.title)}</a></h2>`;
510
+ return `<section>
511
+ ${heading}
512
+ ${list}
513
+ ${more}
514
+ </section>`;
515
+ });
516
+ return `<aside class="hb-sidebar">
517
+ <nav aria-label="Handboek sections">
518
+ ${sections.join("\n")}
519
+ </nav>
520
+ </aside>`;
521
+ }
522
+ function dedupeById(list) {
523
+ const seen = /* @__PURE__ */ new Set();
524
+ return list.filter((e) => !seen.has(e.id) && seen.add(e.id));
525
+ }
526
+ function onThisPage(headings) {
527
+ if (headings.length < 2) return "";
528
+ const items = headings.map((h) => `<li class="hb-h${h.level}"><a href="#${esc(h.id)}">${esc(h.text)}</a></li>`).join("\n");
529
+ return `<aside class="hb-onthispage">
530
+ <nav aria-label="On this page">
531
+ <h2>On this page</h2>
532
+ <ul>
533
+ ${items}
534
+ </ul>
535
+ </nav>
536
+ </aside>`;
537
+ }
538
+ function articlePage(args) {
539
+ const { entry, body, headings, areas, depth, css, siteUrl } = args;
540
+ const area = areas.find((a) => a.area === entry.area);
541
+ const aside = onThisPage(headings);
542
+ return `${head(`${entry.title} \u2014 Gezel Handboek`, css, depth, entry.summary)}
543
+ <body class="hb hb-article-page">
544
+ ${masthead(areas, depth, siteUrl, entry.area)}
545
+ <div class="hb-layout">
546
+ ${sidebar(areas, entry, depth)}
547
+ <main class="hb-main">
548
+ <nav class="hb-breadcrumb" aria-label="Breadcrumb">
549
+ <a href="${up(depth)}">Handboek</a>${area ? ` <span>/</span> <a href="${up(depth)}${esc(areaLanding(area))}/">${esc(area.title)}</a>` : ""}
550
+ </nav>
551
+ <article class="hb-article">
552
+ ${body}
553
+ </article>
554
+ <p class="hb-watch"><a href="watch.html">Watch this article as a slideshow</a></p>
555
+ </main>
556
+ ${aside}
557
+ </div>
558
+ ${footer(depth)}
559
+ </body>
560
+ </html>`;
561
+ }
562
+ function footer(depth) {
563
+ return `<footer class="hb-footer">
564
+ <p><a href="${up(depth)}">Gezel Handboek</a> \u2014 documentation for gezel, a crew of AI companions that works for you, from your own computer.</p>
565
+ </footer>`;
566
+ }
567
+ function landingPage(areas, css, siteUrl) {
568
+ const byId = new Map(areas.flatMap((a) => a.entries).map((e) => [e.id, e]));
569
+ const startHere = START_HERE.map((id) => byId.get(id)).filter(
570
+ (e) => e !== void 0
571
+ );
572
+ const startBlock = startHere.length ? `<section class="hb-start">
573
+ <h2>Start here</h2>
574
+ <ul class="hb-cards">
575
+ ${startHere.map(
576
+ (e) => `<li><a href="${esc(e.id)}/"><span class="hb-card-title">${esc(e.title)}</span>${e.summary ? `<span class="hb-card-summary">${esc(e.summary)}</span>` : ""}</a></li>`
577
+ ).join("\n")}
578
+ </ul>
579
+ </section>` : "";
580
+ const areaBlocks = areas.map((area) => {
581
+ const landing = areaLanding(area);
582
+ const featured = area.entries.filter((e) => e.id !== landing);
583
+ const listed = area.entries.length <= NAV_INLINE_MAX ? featured.slice(0, 8) : [];
584
+ const list = listed.length ? `<ul class="hb-arealist">
585
+ ${listed.map((e) => `<li><a href="${esc(e.id)}/">${esc(e.title)}</a></li>`).join("\n")}
586
+ </ul>` : "";
587
+ return `<section class="hb-area">
588
+ <h2><a href="${esc(landing)}/">${esc(area.title)}</a></h2>
589
+ <p class="hb-area-blurb">${esc(AREA_BLURBS[area.area] ?? "")}</p>
590
+ ${list}
591
+ <p class="hb-more"><a href="${esc(landing)}/">Browse all ${area.entries.length} ${esc(area.title.toLowerCase())}</a></p>
592
+ </section>`;
593
+ }).join("\n");
594
+ return `${head("Gezel Handboek", css, 0, "Documentation for gezel \u2014 a crew of AI companions that works for you, from your own computer.")}
595
+ <body class="hb hb-home">
596
+ ${masthead(areas, 0, siteUrl)}
597
+ <main class="hb-main hb-home-main">
598
+ <section class="hb-hero">
599
+ <h1>The Gezel Handboek</h1>
600
+ <p class="hb-lede">Gezel lets you assemble a crew of AI companions and put them to work \u2014 on your own computer, with your own files. This is their handboek: what they are, what they can do, and how to work with them.</p>
601
+ </section>
602
+ ${startBlock}
603
+ <div class="hb-areas">
604
+ ${areaBlocks}
605
+ </div>
606
+ </main>
607
+ ${footer(0)}
608
+ </body>
609
+ </html>`;
610
+ }
611
+ export {
612
+ extractBody,
613
+ resolveCssHref,
614
+ rewriteSiteLinks,
615
+ runHandboekExport,
616
+ slugify,
617
+ withHeadingIds,
618
+ wrapTables
619
+ };