ssqch 0.7.1 → 0.8.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.
Files changed (153) hide show
  1. package/README.md +6 -4
  2. package/bin/ssqch.js +14 -48
  3. package/bundled/README.md +1247 -0
  4. package/bundled/completions/bash +840 -0
  5. package/bundled/completions/elvish +286 -0
  6. package/bundled/completions/fish +182 -0
  7. package/bundled/completions/powershell +318 -0
  8. package/bundled/completions/zsh +510 -0
  9. package/bundled/ssqch.d.ts +532 -0
  10. package/bundled/starter/engines/index.edge +11 -0
  11. package/bundled/starter/engines/index.ejs +11 -0
  12. package/bundled/starter/engines/index.hbs +11 -0
  13. package/bundled/starter/engines/index.liquid +11 -0
  14. package/bundled/starter/engines/layout.edge +35 -0
  15. package/bundled/starter/engines/layout.ejs +35 -0
  16. package/bundled/starter/engines/layout.hbs +35 -0
  17. package/bundled/starter/engines/layout.liquid +35 -0
  18. package/bundled/starter/gitignore +3 -0
  19. package/bundled/starter/jsconfig.json +11 -0
  20. package/bundled/starter/src/404.md +8 -0
  21. package/bundled/starter/src/_blueprints/posts.md +5 -0
  22. package/bundled/starter/src/_data/site.json +4 -0
  23. package/bundled/starter/src/_includes/layout.jinja +35 -0
  24. package/bundled/starter/src/index.jinja +11 -0
  25. package/bundled/starter/src/posts/i-know-what-i-saw.md +11 -0
  26. package/bundled/starter/src/posts/posts.json +4 -0
  27. package/bundled/starter/src/posts/raiders-of-the-lost-path.md +27 -0
  28. package/bundled/starter/src/posts/the-cache-of-the-wild.md +26 -0
  29. package/bundled/starter/src/posts/the-stump-has-moved.md +15 -0
  30. package/bundled/starter/src/posts/upon-further-review-a-stump.md +18 -0
  31. package/bundled/starter/ssqch.config.js +29 -0
  32. package/bundled/starter-docs/engines/edge/base.edge +41 -0
  33. package/bundled/starter-docs/engines/edge/containers/details.edge +5 -0
  34. package/bundled/starter-docs/engines/edge/containers/tab.edge +4 -0
  35. package/bundled/starter-docs/engines/edge/containers/tabs.edge +5 -0
  36. package/bundled/starter-docs/engines/edge/doc.edge +59 -0
  37. package/bundled/starter-docs/engines/edge/hooks/heading.edge +2 -0
  38. package/bundled/starter-docs/engines/ejs/base.ejs +41 -0
  39. package/bundled/starter-docs/engines/ejs/containers/details.ejs +5 -0
  40. package/bundled/starter-docs/engines/ejs/containers/tab.ejs +4 -0
  41. package/bundled/starter-docs/engines/ejs/containers/tabs.ejs +5 -0
  42. package/bundled/starter-docs/engines/ejs/doc.ejs +59 -0
  43. package/bundled/starter-docs/engines/ejs/hooks/heading.ejs +2 -0
  44. package/bundled/starter-docs/engines/hbs/base.hbs +41 -0
  45. package/bundled/starter-docs/engines/hbs/containers/details.hbs +5 -0
  46. package/bundled/starter-docs/engines/hbs/containers/tab.hbs +4 -0
  47. package/bundled/starter-docs/engines/hbs/containers/tabs.hbs +5 -0
  48. package/bundled/starter-docs/engines/hbs/doc.hbs +58 -0
  49. package/bundled/starter-docs/engines/hbs/hooks/heading.hbs +2 -0
  50. package/bundled/starter-docs/engines/liquid/base.liquid +41 -0
  51. package/bundled/starter-docs/engines/liquid/containers/details.liquid +5 -0
  52. package/bundled/starter-docs/engines/liquid/containers/tab.liquid +4 -0
  53. package/bundled/starter-docs/engines/liquid/containers/tabs.liquid +5 -0
  54. package/bundled/starter-docs/engines/liquid/doc.liquid +60 -0
  55. package/bundled/starter-docs/engines/liquid/hooks/heading.liquid +2 -0
  56. package/bundled/starter-docs/gitignore +4 -0
  57. package/bundled/starter-docs/src/404.md +12 -0
  58. package/bundled/starter-docs/src/_blueprints/docs.md +5 -0
  59. package/bundled/starter-docs/src/_data/nav.yml +10 -0
  60. package/bundled/starter-docs/src/_data/site.json +5 -0
  61. package/bundled/starter-docs/src/_includes/base.jinja +41 -0
  62. package/bundled/starter-docs/src/_includes/containers/details.jinja +5 -0
  63. package/bundled/starter-docs/src/_includes/containers/tab.jinja +4 -0
  64. package/bundled/starter-docs/src/_includes/containers/tabs.jinja +5 -0
  65. package/bundled/starter-docs/src/_includes/doc.jinja +59 -0
  66. package/bundled/starter-docs/src/_includes/hooks/heading.jinja +2 -0
  67. package/bundled/starter-docs/src/assets/docs.css +257 -0
  68. package/bundled/starter-docs/src/assets/docs.js +67 -0
  69. package/bundled/starter-docs/src/docs/docs.json +1 -0
  70. package/bundled/starter-docs/src/docs/guides/deploying.md +77 -0
  71. package/bundled/starter-docs/src/docs/guides/writing.md +65 -0
  72. package/bundled/starter-docs/src/docs/index.md +29 -0
  73. package/bundled/starter-docs/src/docs/install.md +42 -0
  74. package/bundled/starter-docs/src/index.md +13 -0
  75. package/bundled/starter-docs/ssqch.config.js +40 -0
  76. package/bundled/trailheads/from-component-frameworks.md +116 -0
  77. package/bundled/trailheads/from-docusaurus.md +55 -0
  78. package/bundled/trailheads/from-eleventy.md +140 -0
  79. package/bundled/trailheads/from-hexo.md +92 -0
  80. package/bundled/trailheads/from-mkdocs.md +45 -0
  81. package/bundled/trailheads/from-zola.md +71 -0
  82. package/lib/assets.js +235 -3
  83. package/lib/chunk-37KSIVNY.js +29 -0
  84. package/lib/chunk-3GYLOC6Y.js +1017 -0
  85. package/lib/chunk-3NYSSA2C.js +22 -0
  86. package/lib/chunk-3PHCFZEU.js +209 -0
  87. package/lib/chunk-4Q6WMTER.js +32 -0
  88. package/lib/chunk-6XYSFG6V.js +4423 -0
  89. package/lib/chunk-6XYSFG6V.js.LEGAL.txt +41 -0
  90. package/lib/chunk-AD3HAW3W.js +10 -0
  91. package/lib/chunk-AMBFWPZ4.js +118 -0
  92. package/lib/chunk-BOBPVAX2.js +37088 -0
  93. package/lib/chunk-BOBPVAX2.js.LEGAL.txt +27 -0
  94. package/lib/chunk-BRK4MXXO.js +565 -0
  95. package/lib/chunk-C35KIPAR.js +247 -0
  96. package/lib/chunk-CDEPYU7W.js +25 -0
  97. package/lib/chunk-CMUWRPSQ.js +113 -0
  98. package/lib/chunk-DDV6JEC2.js +46 -0
  99. package/lib/chunk-DHHQKW4F.js +71 -0
  100. package/lib/chunk-EIT4ZDT4.js +1485 -0
  101. package/lib/chunk-EZZUUPI4.js +20 -0
  102. package/lib/chunk-F65YUXZ7.js +334 -0
  103. package/lib/chunk-FVZ5JBRI.js +115 -0
  104. package/lib/chunk-FYGE634X.js +44 -0
  105. package/lib/chunk-GOE4ZSAB.js +75 -0
  106. package/lib/chunk-GSKVRAHF.js +44 -0
  107. package/lib/chunk-HR2RU2LY.js +999 -0
  108. package/lib/chunk-HXCLCXRT.js +20 -0
  109. package/lib/chunk-I3PS26CI.js +48 -0
  110. package/lib/chunk-IAFM5ITE.js +11 -0
  111. package/lib/chunk-IRHRK7XB.js +54 -0
  112. package/lib/chunk-JRT7TQQP.js +57 -0
  113. package/lib/chunk-JSPSMIJ2.js +217 -0
  114. package/lib/chunk-KBGE5MCY.js +175 -0
  115. package/lib/chunk-N5QTGQ5N.js +207 -0
  116. package/lib/chunk-NKXEPHRZ.js +136 -0
  117. package/lib/chunk-NUKCUDC4.js +146 -0
  118. package/lib/chunk-RI2L3VGO.js +376 -0
  119. package/lib/chunk-TDGBQNGW.js +251 -0
  120. package/lib/chunk-TN6EEDX2.js +3935 -0
  121. package/lib/chunk-TWCVHOKO.js +1229 -0
  122. package/lib/chunk-UGEGUUBT.js +29 -0
  123. package/lib/chunk-UU43WIZG.js +29 -0
  124. package/lib/chunk-VJWQSYEG.js +119 -0
  125. package/lib/chunk-VVPZ5PDP.js +160 -0
  126. package/lib/chunk-WMOVCQO6.js +1287 -0
  127. package/lib/chunk-WP3RPVUM.js +211 -0
  128. package/lib/chunk-YSH2NMIE.js +502 -0
  129. package/lib/cli.js +540 -0
  130. package/lib/elements.js +180 -3
  131. package/lib/image.js +27 -3
  132. package/lib/links.js +464 -3
  133. package/lib/minify.js +69 -3
  134. package/lib/redirects.js +152 -3
  135. package/lib/rss.js +139 -3
  136. package/lib/sass.js +221 -3
  137. package/lib/sitemap.js +88 -3
  138. package/lib/ssqch.js +28 -0
  139. package/package.json +83 -80
  140. package/src/serve/live.js +174 -0
  141. package/src/serve/not-found.html +31 -0
  142. package/types/globals.d.ts +3 -2
  143. package/types/image.d.ts +7 -3
  144. package/types/index.d.ts +18 -5
  145. package/types/links.d.ts +1 -1
  146. package/types/minify.d.ts +1 -1
  147. package/types/rss.d.ts +1 -1
  148. package/types/sass.d.ts +1 -1
  149. package/wasm/markdown.wasm +0 -0
  150. package/wasm/minify.wasm +0 -0
  151. package/wasm/sass.wasm +0 -0
  152. package/lib/index.js +0 -3
  153. package/platforms.json +0 -6
@@ -0,0 +1,376 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ withBase
5
+ } from "./chunk-TN6EEDX2.js";
6
+ import {
7
+ slugOptions,
8
+ slugWith
9
+ } from "./chunk-EIT4ZDT4.js";
10
+ import {
11
+ BuildError,
12
+ isPlainObject
13
+ } from "./chunk-6XYSFG6V.js";
14
+ import {
15
+ compareText
16
+ } from "./chunk-VJWQSYEG.js";
17
+
18
+ // src/content.ts
19
+ var HEADING = /<h([1-6])(\s[^>]*)?>(.*?)<\/h[1-6]\s*>/gis;
20
+ var ID_ATTR = /(?:^|\s)id\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/i;
21
+ var TAG = /<(\/?)([A-Za-z][A-Za-z0-9-]*)([^>]*)>|<!--.*?-->/gs;
22
+ var HIDDEN = /\saria-hidden\s*=\s*["']?true/i;
23
+ var CODE = /<!--.*?-->|<(pre|code|script|style|template|textarea)\b.*?<\/(?:pre|code|script|style|template|textarea)\s*>/gis;
24
+ var VOID = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
25
+ function headings(html) {
26
+ if (!html.includes("<h") && !html.includes("<H")) return [];
27
+ const out = [];
28
+ for (const found of html.replace(CODE, "").matchAll(HEADING)) {
29
+ const id = ID_ATTR.exec(found[2] ?? "");
30
+ const value = id ? id[1] ?? id[2] ?? id[3] : void 0;
31
+ out.push({ level: Number(found[1]), id: value === void 0 ? void 0 : decodeEntities(value), text: htmlText(found[3]) });
32
+ }
33
+ return out;
34
+ }
35
+ function htmlText(html) {
36
+ let text = "";
37
+ let hidden = 0;
38
+ let last = 0;
39
+ for (const found of html.matchAll(TAG)) {
40
+ if (hidden === 0) text += html.slice(last, found.index);
41
+ last = found.index + found[0].length;
42
+ if (found[2] === void 0) continue;
43
+ const name = found[2].toLowerCase();
44
+ const attrs = found[3] ?? "";
45
+ if (VOID.has(name) || attrs.endsWith("/")) {
46
+ if (name === "br" && hidden === 0) text += " ";
47
+ continue;
48
+ }
49
+ if (found[1] === "/") hidden = Math.max(0, hidden - 1);
50
+ else if (hidden > 0 || HIDDEN.test(attrs)) hidden++;
51
+ }
52
+ if (hidden === 0) text += html.slice(last);
53
+ return splitWhitespace(decodeEntities(text)).join(" ");
54
+ }
55
+ function splitWhitespace(text) {
56
+ return text.split(/[\t-\r \u0085\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]+/).filter((word) => word !== "");
57
+ }
58
+ var ENTITY = /&(#[0-9]{1,7}|#[xX][0-9A-Fa-f]{1,6}|[A-Za-z]+);/g;
59
+ var NAMED = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: "\xA0" };
60
+ function decodeEntities(s) {
61
+ if (!s.includes("&")) return s;
62
+ return s.replace(ENTITY, (whole, name) => {
63
+ if (Object.hasOwn(NAMED, name)) return NAMED[name];
64
+ if (name[0] !== "#") return whole;
65
+ const code = name[1] === "x" || name[1] === "X" ? Number.parseInt(name.slice(2), 16) : Number.parseInt(name.slice(1), 10);
66
+ return code <= 1114111 && !(code >= 55296 && code <= 57343) ? String.fromCodePoint(code) : whole;
67
+ });
68
+ }
69
+ function escapeText(s) {
70
+ return s.replace(/[&<>"]/g, (c) => c === "&" ? "&amp;" : c === "<" ? "&lt;" : c === ">" ? "&gt;" : "&quot;");
71
+ }
72
+ function escapeHtml(s) {
73
+ return s.replace(/[&<>"']/g, (c) => c === "&" ? "&amp;" : c === "<" ? "&lt;" : c === ">" ? "&gt;" : c === '"' ? "&quot;" : "&#39;");
74
+ }
75
+ function excerpt(html) {
76
+ const more = /<!--\s*more\s*-->/.exec(html);
77
+ if (more) return html.slice(0, more.index).trim();
78
+ return /<p(?:\s[^>]*)?>.*?<\/p>/is.exec(html)?.[0];
79
+ }
80
+ function toc(list, from, to, ordered) {
81
+ const tag = ordered ? "ol" : "ul";
82
+ const items = [];
83
+ for (const v of list) {
84
+ const h = v;
85
+ if (typeof h?.level !== "number") continue;
86
+ const level = Math.trunc(h.level);
87
+ const id = typeof h.id === "string" && h.id !== "" ? h.id : void 0;
88
+ if (id !== void 0 && level >= from && level <= to) items.push({ level, id, text: String(h.text) });
89
+ }
90
+ let out = "";
91
+ const stack = [];
92
+ for (const h of items) {
93
+ if (!stack.length) {
94
+ out += `<${tag}>`;
95
+ stack.push(h.level);
96
+ } else {
97
+ while (stack.length > 1 && h.level < stack[stack.length - 1]) {
98
+ out += `</li></${tag}>`;
99
+ stack.pop();
100
+ }
101
+ if (h.level > stack[stack.length - 1]) {
102
+ out += `<${tag}>`;
103
+ stack.push(h.level);
104
+ } else {
105
+ out += "</li>";
106
+ }
107
+ }
108
+ out += `<li><a href="#${escapeHtml(h.id ?? "")}">${escapeText(h.text)}</a>`;
109
+ }
110
+ for (const _ of stack) out += `</li></${tag}>`;
111
+ return out;
112
+ }
113
+
114
+ // src/nav.ts
115
+ var CHILD_KEYS = ["children", "items", "pages"];
116
+ function children(entry) {
117
+ if (!isPlainObject(entry)) return void 0;
118
+ for (const key of CHILD_KEYS) {
119
+ const list = entry[key];
120
+ if (Array.isArray(list) && list.length > 0) return [key, list];
121
+ }
122
+ return void 0;
123
+ }
124
+ var urlOf = (entry) => isPlainObject(entry) && typeof entry.url === "string" ? entry.url : void 0;
125
+ function sameUrl(a, b) {
126
+ return a !== "" && b !== "" && normal(a) === normal(b);
127
+ }
128
+ function normal(url) {
129
+ let u = url.split(/[#?]/)[0];
130
+ if (u.endsWith("index.html")) u = u.slice(0, -"index.html".length);
131
+ return u.replace(/\/+$/, "");
132
+ }
133
+ function buildIndex(entries) {
134
+ const index = { entries, unmarked: entries.map((e) => mark(e, "\0")[0]), paths: /* @__PURE__ */ new Map(), flat: [], position: /* @__PURE__ */ new Map() };
135
+ const walk = (level, prefix) => {
136
+ level.forEach((e, i) => {
137
+ prefix.push(i);
138
+ const url = urlOf(e);
139
+ if (url !== void 0 && url !== "") {
140
+ const key = normal(url);
141
+ const at = index.paths.get(key);
142
+ if (at) at.push([...prefix]);
143
+ else index.paths.set(key, [[...prefix]]);
144
+ if (!index.position.has(key)) index.position.set(key, index.flat.length);
145
+ index.flat.push(withoutChildren(e));
146
+ }
147
+ const below = children(e);
148
+ if (below) walk(below[1], prefix);
149
+ prefix.pop();
150
+ });
151
+ };
152
+ walk(entries, []);
153
+ return index;
154
+ }
155
+ var RECENT = [];
156
+ var SEEN_ONCE = [];
157
+ function indexOf(entries) {
158
+ const found = RECENT.find((i) => i.entries === entries);
159
+ if (found) return found;
160
+ const at = SEEN_ONCE.indexOf(entries);
161
+ if (at < 0) {
162
+ if (SEEN_ONCE.length >= 16) SEEN_ONCE.shift();
163
+ SEEN_ONCE.push(entries);
164
+ return void 0;
165
+ }
166
+ SEEN_ONCE.splice(at, 1);
167
+ const index = buildIndex(entries);
168
+ if (RECENT.length >= 16) RECENT.shift();
169
+ RECENT.push(index);
170
+ return index;
171
+ }
172
+ function markPaths(level, paths) {
173
+ const out = level.slice();
174
+ const firsts = [...new Set(paths.map((p) => p[0]))].sort((a, b) => a - b);
175
+ for (const i of firsts) {
176
+ const entry = level[i];
177
+ if (!isPlainObject(entry)) continue;
178
+ const here = paths.filter((p) => p[0] === i).map((p) => p.slice(1));
179
+ const current = here.some((p) => p.length === 0);
180
+ const below = here.filter((p) => p.length > 0);
181
+ const map = { ...entry };
182
+ if (below.length > 0) {
183
+ const kids = children(entry);
184
+ if (kids) map[kids[0]] = markPaths(kids[1], below);
185
+ }
186
+ map.current = current;
187
+ map.ancestor = below.length > 0;
188
+ map.open = true;
189
+ out[i] = map;
190
+ }
191
+ return out;
192
+ }
193
+ function tree(entries, url) {
194
+ return entries.map((e) => mark(e, url)[0]);
195
+ }
196
+ function treeOf(nav, url) {
197
+ if (!Array.isArray(nav)) return [];
198
+ const index = indexOf(nav);
199
+ if (!index) return tree(nav, url);
200
+ const paths = url === "" ? void 0 : index.paths.get(normal(url));
201
+ return paths ? markPaths(index.unmarked, paths) : index.unmarked.slice();
202
+ }
203
+ function pagerOf(nav, url) {
204
+ if (!Array.isArray(nav)) return pager([], url);
205
+ const index = indexOf(nav);
206
+ if (!index) return pager(nav, url);
207
+ const i = url === "" ? void 0 : index.position.get(normal(url));
208
+ const at = (j) => j === void 0 ? null : index.flat[j] ?? null;
209
+ return { previous: at(i === void 0 || i === 0 ? void 0 : i - 1), next: at(i === void 0 ? void 0 : i + 1) };
210
+ }
211
+ function breadcrumbsOf(nav, url) {
212
+ if (!Array.isArray(nav)) return [];
213
+ const index = indexOf(nav);
214
+ if (!index) return breadcrumbs(nav, url);
215
+ const path = url === "" ? void 0 : index.paths.get(normal(url))?.[0];
216
+ if (!path) return [];
217
+ let level = nav;
218
+ const out = [];
219
+ for (const i of path) {
220
+ const entry = level[i];
221
+ out.push(withoutChildren(entry));
222
+ level = children(entry)?.[1] ?? [];
223
+ }
224
+ return out;
225
+ }
226
+ function mark(entry, url) {
227
+ if (!isPlainObject(entry)) return [entry, false];
228
+ const out = { ...entry };
229
+ const own = urlOf(entry);
230
+ const current = own !== void 0 && sameUrl(own, url);
231
+ let ancestor = false;
232
+ const below = children(entry);
233
+ if (below) {
234
+ out[below[0]] = below[1].map((c) => {
235
+ const [v, found] = mark(c, url);
236
+ ancestor ||= found;
237
+ return v;
238
+ });
239
+ }
240
+ out.current = current;
241
+ out.ancestor = ancestor;
242
+ out.open = current || ancestor;
243
+ return [out, current || ancestor];
244
+ }
245
+ function flatten(entries, out) {
246
+ for (const e of entries) {
247
+ const url = urlOf(e);
248
+ if (url !== void 0 && url !== "") out.push(e);
249
+ const below = children(e);
250
+ if (below) flatten(below[1], out);
251
+ }
252
+ }
253
+ function pager(entries, url) {
254
+ const flat = [];
255
+ flatten(entries, flat);
256
+ const i = flat.findIndex((e) => sameUrl(urlOf(e) ?? "", url));
257
+ const at = (j) => j === void 0 || j < 0 || j >= flat.length ? null : withoutChildren(flat[j]);
258
+ return { previous: at(i < 0 || i === 0 ? void 0 : i - 1), next: at(i < 0 ? void 0 : i + 1) };
259
+ }
260
+ function withoutChildren(e) {
261
+ if (!isPlainObject(e)) return e;
262
+ return Object.fromEntries(Object.entries(e).filter(([k]) => !CHILD_KEYS.includes(k)));
263
+ }
264
+ function breadcrumbs(entries, url) {
265
+ const path = [];
266
+ const walk = (level) => {
267
+ for (const e of level) {
268
+ path.push(withoutChildren(e));
269
+ const own = urlOf(e);
270
+ if (own !== void 0 && sameUrl(own, url)) return true;
271
+ const below = children(e);
272
+ if (below && walk(below[1])) return true;
273
+ path.pop();
274
+ }
275
+ return false;
276
+ };
277
+ return walk(entries) ? path : [];
278
+ }
279
+ function totalCompare(a, b) {
280
+ if (Number.isNaN(a) || Number.isNaN(b)) return Number(Number.isNaN(a)) - Number(Number.isNaN(b));
281
+ if (a < b) return -1;
282
+ if (a > b) return 1;
283
+ if (a === 0 && b === 0) return Number(Object.is(a, 0)) - Number(Object.is(b, 0));
284
+ return 0;
285
+ }
286
+ var get = (v, key) => isPlainObject(v) ? v[key] : void 0;
287
+ function fromPages(items) {
288
+ let nodes = [];
289
+ for (const item of items) {
290
+ const data = get(item, "data");
291
+ const nav = get(data, "nav");
292
+ if (nav === void 0 || nav === null || nav === false) continue;
293
+ const navTitle = get(nav, "title");
294
+ const title = typeof navTitle === "string" ? navTitle : String(get(data, "title"));
295
+ const navKey = get(nav, "key");
296
+ const key = typeof navKey === "string" ? navKey : title;
297
+ const parent = get(nav, "parent");
298
+ const order = get(nav, "order");
299
+ nodes.push({ key, parent: typeof parent === "string" ? parent : void 0, order: typeof order === "number" ? order : Number.MAX_VALUE, entry: { title, url: get(item, "url"), key } });
300
+ }
301
+ const build = (parent, depth) => {
302
+ if (depth > 32) return [];
303
+ const level = nodes.filter((n) => n.parent === parent);
304
+ level.sort((a, b) => totalCompare(a.order, b.order) || compareText(a.entry.title, b.entry.title));
305
+ return level.map((n) => ({ ...n.entry, children: build(n.key, depth + 1) }));
306
+ };
307
+ const keys = new Set(nodes.map((n) => n.key));
308
+ nodes = nodes.map((n) => n.parent !== void 0 && !keys.has(n.parent) ? { ...n, parent: void 0 } : n);
309
+ return build(void 0, 0);
310
+ }
311
+
312
+ // src/filters.ts
313
+ var BUILTIN_FILTERS = [
314
+ ["markdown", '`markdown(text)` renders Markdown with the site\'s options; `markdown(text, "inline")` without the `<p>`.'],
315
+ ["toc", "`toc(page.headings)` is a table of contents; `toc(page.headings, { from: 2, to: 4, ordered: true })` picks the levels."],
316
+ ["navTree", "`navTree(nav, page.url)` marks a navigation tree's entries `current`, `ancestor` or `open`."],
317
+ ["navPager", "`navPager(nav, page.url)` is `{ previous, next }` in reading order."],
318
+ ["navBreadcrumbs", "`navBreadcrumbs(nav, page.url)` is the entries from the top down to the page."],
319
+ ["pagesTree", "`pagesTree(collections.docs)` builds a navigation tree from pages' `nav` front matter."],
320
+ ["highlight", "`highlight(code, lang)` is highlighted HTML for inside a `<code>`, with `hl-*` classes."],
321
+ ["readingTime", "`readingTime(content)` is the minutes it takes to read some HTML, at 200 words a minute."],
322
+ ["withBase", '`withBase("/feed.xml")` puts the site\'s `base` in front of a URL, for places outside HTML attributes.'],
323
+ ["slugify", '`slugify("Pine Cone Crunch!")` is `pine-cone-crunch`: lowercase letters and digits, with a dash for each run of anything else; `slugify(title, { separator: "_" })` uses another separator, and `apostrophes: "separate"` splits words at an apostrophe instead of dropping it.']
324
+ ];
325
+ function builtinFilters(markdown, config) {
326
+ const filters = /* @__PURE__ */ new Map();
327
+ filters.set("markdown", (text, option) => {
328
+ const inline = option === "inline" || isPlainObject(option) && Boolean(option.inline);
329
+ return markdown.html(text === void 0 || text === null ? "" : String(text), inline);
330
+ });
331
+ filters.set("highlight", (...args) => {
332
+ const code = args.length > 0 ? String(args[0]) : "";
333
+ const lang = args.length > 1 ? String(args[1]) : "";
334
+ return markdown.highlight(code, lang) ?? escapeText(code);
335
+ });
336
+ const urlArg = (args) => args.length > 1 ? String(args[1]) : "";
337
+ filters.set("navTree", (...args) => treeOf(args[0], urlArg(args)));
338
+ filters.set("navPager", (...args) => pagerOf(args[0], urlArg(args)));
339
+ filters.set("navBreadcrumbs", (...args) => breadcrumbsOf(args[0], urlArg(args)));
340
+ filters.set("pagesTree", (...args) => fromPages(Array.isArray(args[0]) ? args[0] : []));
341
+ filters.set("slugify", (text, option) => {
342
+ const [separator, apostrophes] = slugOptions(option);
343
+ return slugWith(String(text), separator, apostrophes);
344
+ });
345
+ filters.set("readingTime", (text, wordsPerMinute) => {
346
+ const wpm = typeof wordsPerMinute === "number" && wordsPerMinute > 0 ? wordsPerMinute : 200;
347
+ const words = splitWhitespace(htmlText(String(text))).length;
348
+ return Math.max(Math.ceil(words / wpm), 1);
349
+ });
350
+ filters.set("toc", (list, option, last) => {
351
+ const headings2 = Array.isArray(list) ? list : [];
352
+ let [from, to, ordered] = [2, 3, false];
353
+ if (isPlainObject(option)) {
354
+ for (const key of Object.keys(option)) {
355
+ if (!["from", "to", "ordered"].includes(key)) throw new BuildError(`toc: unknown option \`${key}\` (options: from, to, ordered)`);
356
+ }
357
+ if (typeof option.from === "number") from = option.from;
358
+ if (typeof option.to === "number") to = option.to;
359
+ ordered = Boolean(option.ordered);
360
+ } else if (typeof option === "number") {
361
+ from = option;
362
+ to = typeof last === "number" ? last : Math.max(to, from);
363
+ }
364
+ const level = (n) => Math.trunc(Math.min(Math.max(n, 1), 6));
365
+ return toc(headings2, level(from), level(to), ordered);
366
+ });
367
+ filters.set("withBase", (url) => withBase(config.base, url === void 0 ? "" : String(url)));
368
+ return filters;
369
+ }
370
+
371
+ export {
372
+ headings,
373
+ excerpt,
374
+ BUILTIN_FILTERS,
375
+ builtinFilters
376
+ };
@@ -0,0 +1,251 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ quoted
5
+ } from "./chunk-CMUWRPSQ.js";
6
+ import {
7
+ bail
8
+ } from "./chunk-6XYSFG6V.js";
9
+
10
+ // src/glob.ts
11
+ var stripDot = (p) => p.replace(/^(\.\/)+/, "");
12
+ var GlobProblem = class extends Error {
13
+ };
14
+ var UNOPENED = "unopened alternate group; missing '{' (maybe escape '}' with '[}]'?)";
15
+ var UNCLOSED = "unclosed alternate group; missing '}' (maybe escape '{' with '[{]'?)";
16
+ function parse(glob, windows) {
17
+ const isSeparator = (c) => c === "/" || windows && c === "\\";
18
+ const chars = [...glob];
19
+ let at = 0;
20
+ let prev, cur;
21
+ const bump = () => {
22
+ prev = cur;
23
+ cur = chars[at++];
24
+ return cur;
25
+ };
26
+ const peek = () => chars[at];
27
+ const stack = [];
28
+ const branches = [[]];
29
+ const push = (token) => {
30
+ const last = branches[branches.length - 1];
31
+ if (!last) throw new GlobProblem(UNOPENED);
32
+ last.push(token);
33
+ };
34
+ const star = () => {
35
+ const before = prev;
36
+ if (peek() !== "*") return push({ kind: "zeroOrMore" });
37
+ bump();
38
+ if (!branches[branches.length - 1].length) {
39
+ if (peek() !== void 0 && !isSeparator(peek())) {
40
+ push({ kind: "zeroOrMore" });
41
+ push({ kind: "zeroOrMore" });
42
+ } else {
43
+ push({ kind: "recursivePrefix" });
44
+ bump();
45
+ }
46
+ return;
47
+ }
48
+ if (!isSeparator(before) && (branches.length <= 1 || before !== "," && before !== "{")) {
49
+ push({ kind: "zeroOrMore" });
50
+ push({ kind: "zeroOrMore" });
51
+ return;
52
+ }
53
+ let suffix;
54
+ const next = peek();
55
+ if (next === void 0) {
56
+ bump();
57
+ suffix = true;
58
+ } else if ((next === "," || next === "}") && branches.length >= 2) suffix = true;
59
+ else if (isSeparator(next)) {
60
+ bump();
61
+ suffix = false;
62
+ } else {
63
+ push({ kind: "zeroOrMore" });
64
+ push({ kind: "zeroOrMore" });
65
+ return;
66
+ }
67
+ const popped = branches[branches.length - 1].pop();
68
+ if (popped.kind === "recursivePrefix" || popped.kind === "recursiveSuffix") push(popped);
69
+ else push({ kind: suffix ? "recursiveSuffix" : "recursiveZeroOrMore" });
70
+ };
71
+ const cls = () => {
72
+ const ranges = [];
73
+ const extend = (range, c) => {
74
+ range[1] = c;
75
+ if (range[1].codePointAt(0) < range[0].codePointAt(0)) throw new GlobProblem(`invalid range; '${range[0]}' > '${range[1]}'`);
76
+ };
77
+ let negated = false;
78
+ if (peek() === "!" || peek() === "^") {
79
+ bump();
80
+ negated = true;
81
+ }
82
+ let first = true, inRange = false;
83
+ for (; ; ) {
84
+ const c = bump();
85
+ if (c === void 0) throw new GlobProblem("unclosed character class; missing ']'");
86
+ if (c === "]") {
87
+ if (!first) break;
88
+ ranges.push(["]", "]"]);
89
+ } else if (c === "-") {
90
+ if (first) ranges.push(["-", "-"]);
91
+ else if (inRange) {
92
+ extend(ranges[ranges.length - 1], "-");
93
+ inRange = false;
94
+ } else inRange = true;
95
+ } else {
96
+ if (inRange) extend(ranges[ranges.length - 1], c);
97
+ else ranges.push([c, c]);
98
+ inRange = false;
99
+ }
100
+ first = false;
101
+ }
102
+ if (inRange) ranges.push(["-", "-"]);
103
+ push({ kind: "class", negated, ranges });
104
+ };
105
+ for (let c = bump(); c !== void 0; c = bump()) {
106
+ if (c === "?") push({ kind: "any" });
107
+ else if (c === "*") star();
108
+ else if (c === "[") cls();
109
+ else if (c === "{") {
110
+ stack.push(branches.length);
111
+ branches.push([]);
112
+ } else if (c === "}") {
113
+ const start = stack.pop();
114
+ if (start === void 0) throw new GlobProblem(UNOPENED);
115
+ push({ kind: "alternates", branches: branches.splice(start) });
116
+ } else if (c === ",") {
117
+ if (!stack.length) push({ kind: "literal", char: "," });
118
+ else branches.push([]);
119
+ } else if (c === "\\") {
120
+ if (!windows) {
121
+ const next = bump();
122
+ if (next === void 0) throw new GlobProblem("dangling '\\'");
123
+ push({ kind: "literal", char: next });
124
+ } else push({ kind: "literal", char: "/" });
125
+ } else push({ kind: "literal", char: c });
126
+ }
127
+ if (branches.length > 1) throw new GlobProblem(UNCLOSED);
128
+ return branches[0];
129
+ }
130
+ var code = (c) => c.codePointAt(0);
131
+ var isAsciiLetter = (n) => n >= 65 && n <= 90 || n >= 97 && n <= 122;
132
+ var charCode = (n) => /[0-9A-Za-z]/.test(String.fromCodePoint(n)) ? String.fromCodePoint(n) : `\\u{${n.toString(16)}}`;
133
+ var charLiteral = (n, ignoreCase) => ignoreCase && isAsciiLetter(n) ? `[${String.fromCharCode(n | 32)}${String.fromCharCode(n & ~32)}]` : charCode(n);
134
+ function classPattern(negated, ranges, ignoreCase) {
135
+ const items = ranges.map(([from, to]) => [code(from), code(to)]);
136
+ if (ignoreCase) {
137
+ for (const [lo, hi] of [...items]) {
138
+ for (const [start, end, shift] of [[65, 90, 32], [97, 122, -32]]) {
139
+ const l = Math.max(lo, start), h = Math.min(hi, end);
140
+ if (l <= h) items.push([l + shift, h + shift]);
141
+ }
142
+ }
143
+ }
144
+ return `[${negated ? "^" : ""}${items.map(([lo, hi]) => lo === hi ? charCode(lo) : `${charCode(lo)}-${charCode(hi)}`).join("")}]`;
145
+ }
146
+ function tokensPattern(tokens, ignoreCase) {
147
+ let re = "";
148
+ for (const token of tokens) {
149
+ switch (token.kind) {
150
+ case "literal":
151
+ re += [...token.char].map((c) => charLiteral(code(c), ignoreCase)).join("");
152
+ break;
153
+ case "any":
154
+ re += "[^/]";
155
+ break;
156
+ case "zeroOrMore":
157
+ re += "[^/]*";
158
+ break;
159
+ case "recursivePrefix":
160
+ re += "(?:/?|.*/)";
161
+ break;
162
+ case "recursiveSuffix":
163
+ re += "/.*";
164
+ break;
165
+ case "recursiveZeroOrMore":
166
+ re += "(?:/|/.*/)";
167
+ break;
168
+ case "class":
169
+ re += classPattern(token.negated, token.ranges, ignoreCase);
170
+ break;
171
+ case "alternates": {
172
+ const parts = token.branches.map((branch) => tokensPattern(branch, ignoreCase)).filter((part) => part !== "");
173
+ if (parts.length) re += `(?:${parts.join("|")})`;
174
+ }
175
+ }
176
+ }
177
+ return re;
178
+ }
179
+ var WINDOWS = process.platform === "win32";
180
+ function globToRegExp(glob, { ignoreCase = false, loose = false, windows = WINDOWS } = {}) {
181
+ if (loose) return looseGlobToRegExp(glob);
182
+ const tokens = parse(stripDot(glob), windows);
183
+ const re = tokens.length === 1 && tokens[0].kind === "recursivePrefix" ? ".*" : tokensPattern(tokens, ignoreCase);
184
+ return new RegExp(`^${re}$`, "su");
185
+ }
186
+ function looseGlobToRegExp(glob) {
187
+ const g = stripDot(glob);
188
+ let re = "";
189
+ let braces = 0;
190
+ for (let i = 0; i < g.length; i++) {
191
+ const c = g[i];
192
+ if (c === "*" && g[i + 1] === "*") {
193
+ const slash = g[i + 2] === "/";
194
+ re += slash ? "(?:.*/)?" : ".*";
195
+ i += slash ? 2 : 1;
196
+ } else if (c === "*") re += "[^/]*";
197
+ else if (c === "?") re += "[^/]";
198
+ else if (c === "[") {
199
+ const end = g.indexOf("]", i);
200
+ if (end === -1) re += "\\[";
201
+ else {
202
+ re += "[" + g.slice(i + 1, end).replace(/^!/, "^").replace(/\\/g, "\\\\") + "]";
203
+ i = end;
204
+ }
205
+ } else if (c === "{") {
206
+ braces++;
207
+ re += "(?:";
208
+ } else if (c === "}" && braces) {
209
+ braces--;
210
+ re += ")";
211
+ } else if (c === "," && braces) re += "|";
212
+ else re += c.replace(/[.+^$()|\\{}\]]/g, "\\$&");
213
+ }
214
+ return new RegExp(`^${re}$`);
215
+ }
216
+ function globProblem(glob, { windows = WINDOWS } = {}) {
217
+ try {
218
+ parse(stripDot(glob), windows);
219
+ return void 0;
220
+ } catch (e) {
221
+ if (e instanceof GlobProblem) return e.message;
222
+ throw e;
223
+ }
224
+ }
225
+ var isGlob = (p) => /[*?[{]/.test(p);
226
+ function globBase(glob) {
227
+ const fixed = [];
228
+ for (const part of stripDot(glob).split("/")) {
229
+ if (isGlob(part)) break;
230
+ fixed.push(part);
231
+ }
232
+ return fixed.join("/");
233
+ }
234
+ function globSet(what, globs) {
235
+ const patterns = [...globs].map((given) => {
236
+ const glob = stripDot(given);
237
+ const problem = globProblem(glob);
238
+ if (problem !== void 0) bail(`${what}: invalid glob ${quoted(glob)}: error parsing glob '${glob}': ${problem}`);
239
+ return globToRegExp(glob);
240
+ });
241
+ if (!patterns.length) return () => false;
242
+ return (p) => patterns.some((re) => re.test(p));
243
+ }
244
+
245
+ export {
246
+ globToRegExp,
247
+ globProblem,
248
+ isGlob,
249
+ globBase,
250
+ globSet
251
+ };