ssqch 0.10.1 → 0.11.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 (93) hide show
  1. package/bundled/completions/bash +61 -15
  2. package/bundled/completions/elvish +27 -12
  3. package/bundled/completions/fish +35 -23
  4. package/bundled/completions/powershell +29 -12
  5. package/bundled/completions/zsh +39 -19
  6. package/bundled/docs/agents.md +11 -0
  7. package/bundled/docs/comparing-builds.md +37 -5
  8. package/bundled/docs/configuring.md +30 -5
  9. package/bundled/docs/field-guide.md +1 -1
  10. package/bundled/docs/github-pages.md +1 -1
  11. package/bundled/docs/index.md +1 -1
  12. package/bundled/docs/known-gaps.md +1 -1
  13. package/bundled/docs/markdown.md +63 -5
  14. package/bundled/docs/multilingual.md +20 -3
  15. package/bundled/docs/nav.yml +1 -0
  16. package/bundled/docs/netlify.md +2 -2
  17. package/bundled/docs/plugins.md +4 -4
  18. package/bundled/docs/seo.md +39 -1
  19. package/bundled/docs/template-languages.md +6 -4
  20. package/bundled/docs/templates.md +3 -3
  21. package/bundled/docs/trailheads/from-eleventy.md +25 -13
  22. package/bundled/docs/trailheads/from-hugo.md +103 -0
  23. package/bundled/docs/trailheads/from-jekyll.md +49 -15
  24. package/bundled/docs/trailheads/from-mkdocs.md +54 -9
  25. package/bundled/docs/trailheads/from-zola.md +2 -2
  26. package/bundled/docs/trailheads.md +22 -5
  27. package/bundled/docs/where-values-come-from.md +1 -1
  28. package/bundled/mkdocs/404.jinja +6 -0
  29. package/bundled/ssqch.d.ts +71 -16
  30. package/lib/assets.js +10 -9
  31. package/lib/{chunk-MUYWL4ZX.js → chunk-2L3HR67O.js} +71 -18
  32. package/lib/{chunk-ERNVEZOK.js → chunk-2QTJTEBV.js} +1 -1
  33. package/lib/{chunk-CXRHH5P5.js → chunk-3HZZY3Y7.js} +5 -5
  34. package/lib/{chunk-G67W2FTJ.js → chunk-3K237XAX.js} +9 -8
  35. package/lib/{chunk-6RSZV5O2.js → chunk-443ZQLVX.js} +3 -3
  36. package/lib/{chunk-ZZBHBLDB.js → chunk-5ELAUHRL.js} +18 -16
  37. package/lib/{chunk-MDG5A4NI.js → chunk-A75EVUJX.js} +5 -5
  38. package/lib/{chunk-JFPLNHEQ.js → chunk-AIMEXBTK.js} +28 -5
  39. package/lib/{chunk-6OUT5VFK.js → chunk-B5E27PLU.js} +10 -39
  40. package/lib/{chunk-R2YGC3VE.js → chunk-CMJ7X5WW.js} +3 -2
  41. package/lib/{chunk-MDB3D3LP.js → chunk-ERAIEV3O.js} +2 -2
  42. package/lib/{chunk-DTSTCVRX.js → chunk-FCM3NYFR.js} +11 -8
  43. package/lib/{chunk-X7C6GFUM.js → chunk-GJNIQAIH.js} +8 -8
  44. package/lib/{chunk-FYRC2HBU.js → chunk-GLJQ4C76.js} +39 -18
  45. package/lib/{chunk-BXARVN5Z.js → chunk-GS5B3CBW.js} +1 -1
  46. package/lib/chunk-H5K2ZE7B.js +219 -0
  47. package/lib/{chunk-DNWA7WNO.js → chunk-HFSWUTXX.js} +1 -1
  48. package/lib/{chunk-7JGYYAKI.js → chunk-HWW5NCVJ.js} +1 -1
  49. package/lib/{chunk-BT3NVQOD.js → chunk-I3HYKEEW.js} +1 -1
  50. package/lib/{chunk-RFNLZM7W.js → chunk-IOBC665M.js} +1 -1
  51. package/lib/chunk-JC54PHIT.js +7992 -0
  52. package/lib/{chunk-3BQJY6GF.js → chunk-KCF2Z6N7.js} +1 -1
  53. package/lib/{chunk-HMVYNV6M.js → chunk-KZZS4W2V.js} +14 -12
  54. package/lib/{chunk-XR7GFL4B.js → chunk-LJOURBYT.js} +14 -12
  55. package/lib/chunk-OQGXZYZS.js +45 -0
  56. package/lib/chunk-OSBEH67S.js +6296 -0
  57. package/lib/{chunk-FYU22VDK.js → chunk-QJ5ZFTML.js} +14 -12
  58. package/lib/{chunk-LU73FTIR.js → chunk-QLUTNR37.js} +11 -10
  59. package/lib/{chunk-DUGGZ4EE.js → chunk-RBNPBTDP.js} +1 -1
  60. package/lib/{chunk-F65YUXZ7.js → chunk-RIAOXEXC.js} +10 -4
  61. package/lib/chunk-RVXGUMFI.js +21 -0
  62. package/lib/{chunk-FZGJUJAL.js → chunk-RYIWYWRQ.js} +3 -3
  63. package/lib/{chunk-LYPKL524.js → chunk-RZYAIX2R.js} +12 -10
  64. package/lib/{chunk-3NDFUMV2.js → chunk-V2FSMOFX.js} +3 -3
  65. package/lib/{chunk-26SHWRC6.js → chunk-X2GAVYV2.js} +524 -72
  66. package/lib/chunk-XS4EJSEK.js +279 -0
  67. package/lib/chunk-YCOTX2VM.js +37 -0
  68. package/lib/{chunk-P2TRR6XK.js → chunk-Z44IAMNG.js} +85 -16
  69. package/lib/chunk-Z5OP43HU.js +2945 -0
  70. package/lib/{chunk-3LODFCCH.js → chunk-ZINLHOX4.js} +2 -2
  71. package/lib/{chunk-HNG372DW.js → chunk-ZR3JYLFB.js} +814 -12347
  72. package/lib/cli.js +78 -37
  73. package/lib/elements.js +10 -9
  74. package/lib/image.js +11 -10
  75. package/lib/links.js +10 -9
  76. package/lib/minify.js +71 -12
  77. package/lib/redirects.js +10 -9
  78. package/lib/rss.js +13 -10
  79. package/lib/sass.js +13 -243
  80. package/lib/sitemap.js +18 -15
  81. package/lib/ssqch.js +6 -4
  82. package/package.json +1 -1
  83. package/types/index.d.ts +52 -11
  84. package/types/minify.d.ts +15 -3
  85. package/types/sass.d.ts +2 -0
  86. package/types/sitemap.d.ts +2 -2
  87. package/wasm/markdown.wasm +0 -0
  88. package/wasm/minify.wasm +0 -0
  89. package/wasm/sass.wasm +0 -0
  90. package/lib/chunk-II7ZRIAC.js +0 -1285
  91. package/lib/chunk-IOXCGMSF.js +0 -1539
  92. /package/lib/{chunk-JFPLNHEQ.js.LEGAL.txt → chunk-AIMEXBTK.js.LEGAL.txt} +0 -0
  93. /package/lib/{chunk-HNG372DW.js.LEGAL.txt → chunk-ZR3JYLFB.js.LEGAL.txt} +0 -0
package/lib/sass.js CHANGED
@@ -1,254 +1,24 @@
1
1
  import { createRequire as __ssqchCreateRequire } from "node:module";
2
2
  const require = __ssqchCreateRequire(import.meta.url);
3
3
  import {
4
- startReading
5
- } from "./chunk-3NYSSA2C.js";
6
- import {
7
- Options
8
- } from "./chunk-DUGGZ4EE.js";
9
- import {
10
- BUILTINS,
11
- cssWithBase,
12
- debugString,
13
- wasi
14
- } from "./chunk-P2TRR6XK.js";
15
- import "./chunk-ERNVEZOK.js";
16
- import "./chunk-MDB3D3LP.js";
4
+ sassPlugin
5
+ } from "./chunk-XS4EJSEK.js";
6
+ import "./chunk-3NYSSA2C.js";
7
+ import "./chunk-RBNPBTDP.js";
8
+ import "./chunk-Z44IAMNG.js";
9
+ import "./chunk-2QTJTEBV.js";
10
+ import "./chunk-ERAIEV3O.js";
17
11
  import "./chunk-AD3HAW3W.js";
18
- import "./chunk-BXARVN5Z.js";
19
- import {
20
- WebAssembly
21
- } from "./chunk-IOXCGMSF.js";
12
+ import "./chunk-YCOTX2VM.js";
13
+ import "./chunk-GS5B3CBW.js";
14
+ import "./chunk-JC54PHIT.js";
15
+ import "./chunk-HFSWUTXX.js";
22
16
  import "./chunk-FVZ5JBRI.js";
23
- import "./chunk-DNWA7WNO.js";
24
17
  import "./chunk-UU43WIZG.js";
25
- import "./chunk-RFNLZM7W.js";
18
+ import "./chunk-IOBC665M.js";
26
19
  import "./chunk-CMUWRPSQ.js";
27
- import {
28
- BuildError,
29
- bail,
30
- comparePaths,
31
- displayPath,
32
- isInside,
33
- messageOf,
34
- realPath,
35
- slashes
36
- } from "./chunk-JFPLNHEQ.js";
20
+ import "./chunk-AIMEXBTK.js";
37
21
  import "./chunk-I3PS26CI.js";
38
-
39
- // src/modules/sass.ts
40
- import fs from "node:fs";
41
- import path from "node:path";
42
- import { fileURLToPath } from "node:url";
43
- function sassPlugin(options = {}) {
44
- return { name: "ssqch/sass", builtin: "ssqch/sass", options };
45
- }
46
- var isSass = (file) => file.endsWith(".scss") || file.endsWith(".sass");
47
- function entries(root, from, to) {
48
- const src = path.resolve(root, from);
49
- const stat = fs.statSync(src, { throwIfNoEntry: false });
50
- if (stat?.isFile()) {
51
- if (!isSass(src)) bail(`files: ${from} isn't a .scss or .sass file`);
52
- return [[src, to.endsWith("/") ? `${to}${path.basename(src).replace(/\.s[ac]ss$/, "")}.css` : to]];
53
- }
54
- if (!stat?.isDirectory()) bail(`files: ${from} doesn't exist`);
55
- const out = [];
56
- const walk = (dir) => {
57
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
58
- const file = path.join(dir, entry.name);
59
- if (entry.isDirectory()) walk(file);
60
- else if (entry.isFile() && isSass(entry.name) && !entry.name.startsWith("_")) {
61
- out.push([file, `${to.replace(/\/+$/, "")}/${slashes(path.relative(src, file)).replace(/\.s[ac]ss$/, "")}.css`]);
62
- }
63
- }
64
- };
65
- walk(src);
66
- return out.sort((a, b) => comparePaths(a[0], b[0]) || (a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0));
67
- }
68
- BUILTINS.set("ssqch/sass", (config, given) => {
69
- const o = new Options(given, ["files", "style", "loadPaths"]);
70
- const files = [];
71
- const map = o.get("files");
72
- if (map !== void 0) {
73
- if (typeof map !== "object" || Array.isArray(map)) bail('files must be an object of { source: "/output" }');
74
- for (const [from, to] of Object.entries(map)) {
75
- if (typeof to !== "string") bail(`files.${from}: the output must be a URL path string`);
76
- files.push([from, to]);
77
- }
78
- }
79
- const style = o.string("style");
80
- if (style !== void 0 && style !== "compressed" && style !== "expanded") bail(`style must be "compressed" or "expanded", not ${debugString(style)}`);
81
- const loadPaths = o.list("loadPaths") ?? [];
82
- if (!files.length) bail('files is required: { "src/scss": "/css" } or { "src/app.scss": "/app.css" }');
83
- for (const [from, to] of files) {
84
- if (!to.startsWith("/") || to.includes("..")) bail(`files: ${debugString(to)} must be a URL path starting with / (like "/css/app.css" or "/css")`);
85
- if (from === "") bail("files: a source path can't be empty");
86
- }
87
- for (const [from] of files) {
88
- config.watch.push(from);
89
- const slash = Math.max(from.lastIndexOf("/"), from.lastIndexOf(path.sep));
90
- const dir = slash < 0 ? "" : slash === 0 ? from.slice(0, 1) : from.slice(0, slash);
91
- if (isSass(from) && dir !== "") config.watch.push(dir);
92
- }
93
- for (const dir of loadPaths) config.watch.push(dir);
94
- let count;
95
- config.fileBuilders.push(["ssqch/sass", (config2) => {
96
- const chosen = style ?? (config2.env === "production" && !config2.serving ? "compressed" : "expanded");
97
- const used = startReading(config2, "ssqch/sass");
98
- const compiler = new Compiler(config2.root, used, loadPaths.map((dir) => path.resolve(config2.root, dir)));
99
- const options = JSON.stringify({ style: chosen, loadPaths: loadPaths.map((dir) => compiler.name(path.resolve(config2.root, dir))) });
100
- const out = [];
101
- for (const [from, to] of files) {
102
- for (const [src, url] of entries(config2.root, from, to)) {
103
- const shown = displayPath(config2.root, src);
104
- const css = compiler.compile(src, options, shown);
105
- out.push({ path: url, contents: cssWithBase(config2.base, css) });
106
- }
107
- }
108
- count = [out.length, chosen];
109
- return out;
110
- }]);
111
- config.summaries.push(["Sass", () => count === void 0 ? void 0 : `${count[0]} file${count[0] === 1 ? "" : "s"} (${count[1]})`]);
112
- });
113
- var WASM_FILE = fileURLToPath(new URL("../../wasm/sass.wasm", new URL("../src/modules/sass.ts", import.meta.url).href));
114
- var compiled;
115
- var current;
116
- var active;
117
- var Compiler = class {
118
- root;
119
- used;
120
- loadPaths;
121
- constructor(root, used, loadPaths = []) {
122
- this.root = root;
123
- this.used = used;
124
- this.loadPaths = loadPaths;
125
- }
126
- /**
127
- * A stylesheet as grass should read it. Two things other compilers take that grass doesn't:
128
- *
129
- * - Front matter (Jekyll's `---` lines at the top of a site's main stylesheet) becomes blank
130
- * lines, so error lines still match the file. Sass can't start with `---`, so nothing that
131
- * compiled before reads differently.
132
- * - An `@import`, `@use` or `@forward` that names its extension (`"primer-core/index.scss"`)
133
- * is found in the load paths too: grass 0.13 looks for one only beside the importing file
134
- * (`find_import`, "todo: consider load paths"), and Dart Sass and Ruby Sass look in both.
135
- * Where the file isn't beside the importer but is in a load path, the import names it from
136
- * the importer's folder. primer's packages all import this way (opensource.guide, osg #10).
137
- */
138
- source(file, data) {
139
- if (!isSass(file)) return data;
140
- let text = data.toString("utf8");
141
- const front = /^---[ \t]*\r?\n(?:[\s\S]*?\r?\n)?---[ \t]*(?:\r?\n|$)/.exec(text);
142
- if (front) text = front[0].replace(/[^\n]/g, "") + text.slice(front[0].length);
143
- const dir = path.dirname(file);
144
- const exists = (base, name) => {
145
- const full = path.resolve(base, name);
146
- const partial = path.join(path.dirname(full), `_${path.basename(full)}`);
147
- return fs.existsSync(full) ? full : fs.existsSync(partial) ? partial : void 0;
148
- };
149
- const changed = text.replace(/@(import|use|forward)(\s+)([^;{}]+)/g, (statement, rule, space, rest) => `@${rule}${space}${rest.replace(/(["'])([^"'\n]+\.s[ac]ss)\1/g, (quoted, q, name) => {
150
- if (path.isAbsolute(name) || /^[a-z]+:/i.test(name) || exists(dir, name)) return quoted;
151
- for (const load of this.loadPaths) {
152
- const found = exists(load, name);
153
- if (found) return `${q}${slashes(path.relative(dir, path.join(path.dirname(found), path.basename(name))))}${q}`;
154
- }
155
- return quoted;
156
- })}`);
157
- return front || changed !== text ? Buffer.from(changed, "utf8") : data;
158
- }
159
- /** A path as grass sees it: from the root for the site's own files, else whole; with `/`. */
160
- name(file) {
161
- return isInside(this.root, file) && file !== this.root ? slashes(path.relative(this.root, file)) : slashes(file);
162
- }
163
- /** A path grass gave back, as a real one. */
164
- file(name) {
165
- return path.resolve(this.root, name);
166
- }
167
- compile(src, options, shown) {
168
- const x = instance();
169
- const parts = [this.name(src), options];
170
- const lens = parts.map((p) => Buffer.byteLength(p, "utf8"));
171
- const ptr = x.sass_alloc(lens[0] + lens[1]);
172
- const bytes = Buffer.from(x.memory.buffer);
173
- bytes.write(parts[0], ptr, lens[0], "utf8");
174
- bytes.write(parts[1], ptr + lens[0], lens[1], "utf8");
175
- active = this;
176
- let status;
177
- try {
178
- status = x.sass_compile(ptr, lens[0], lens[1]);
179
- } catch (e) {
180
- current = void 0;
181
- let message = messageOf(e);
182
- if (e instanceof WebAssembly.RuntimeError) {
183
- try {
184
- x.sass_panic();
185
- message = resultOf(x) || message;
186
- } catch {
187
- }
188
- }
189
- throw new BuildError(`compiling ${shown}: ssqch's Sass crashed (${message.replace(/\s*\n\s*/g, " ")})`);
190
- } finally {
191
- active = void 0;
192
- }
193
- const text = resultOf(x);
194
- if (status !== 0) throw new BuildError(`compiling ${shown}: ${shown}: ${text}`);
195
- return text;
196
- }
197
- };
198
- function resultOf(x) {
199
- const ptr = x.sass_result_ptr();
200
- return Buffer.from(x.memory.buffer).toString("utf8", ptr, ptr + x.sass_result_len());
201
- }
202
- function instance() {
203
- if (current) return current;
204
- if (!compiled) {
205
- let bytes;
206
- try {
207
- bytes = fs.readFileSync(WASM_FILE);
208
- } catch (e) {
209
- throw new BuildError(`ssqch's Sass isn't there (${WASM_FILE}: ${messageOf(e)}); build it with node packages/ssqch/scripts/build-wasm.ts sass`);
210
- }
211
- compiled = new WebAssembly.Module(bytes);
212
- }
213
- let x;
214
- const memory = () => x.memory;
215
- const text = (ptr, len) => Buffer.from(x.memory.buffer).toString("utf8", ptr, ptr + len);
216
- const reply = (out, status, answer) => {
217
- const data = typeof answer === "string" ? Buffer.from(answer, "utf8") : answer;
218
- const ptr = x.sass_alloc(data.length);
219
- const bytes = Buffer.from(x.memory.buffer);
220
- bytes.set(data, ptr);
221
- bytes.writeUInt32LE(ptr, out);
222
- bytes.writeUInt32LE(data.length, out + 4);
223
- return status;
224
- };
225
- const stat = (ptr, len) => fs.statSync(active.file(text(ptr, len)), { throwIfNoEntry: false });
226
- const host = {
227
- is_file: (ptr, len) => stat(ptr, len)?.isFile() ? 1 : 0,
228
- is_dir: (ptr, len) => stat(ptr, len)?.isDirectory() ? 1 : 0,
229
- read: (ptr, len, out) => {
230
- const file = active.file(text(ptr, len));
231
- try {
232
- const data = active.source(file, fs.readFileSync(file));
233
- active.used.add(realPath(file));
234
- return reply(out, 0, data);
235
- } catch (e) {
236
- return reply(out, 1, messageOf(e));
237
- }
238
- },
239
- // The same file under two names is one module (grass uses it to load each once).
240
- canonicalize: (ptr, len, out) => {
241
- try {
242
- return reply(out, 0, active.name(fs.realpathSync.native(active.file(text(ptr, len)))));
243
- } catch (e) {
244
- return reply(out, 1, messageOf(e));
245
- }
246
- }
247
- };
248
- x = new WebAssembly.Instance(compiled, { wasi_snapshot_preview1: wasi(memory), ssqch: host }).exports;
249
- x._initialize();
250
- return current = x;
251
- }
252
22
  export {
253
23
  sassPlugin
254
24
  };
package/lib/sitemap.js CHANGED
@@ -2,30 +2,33 @@ import { createRequire as __ssqchCreateRequire } from "node:module";
2
2
  const require = __ssqchCreateRequire(import.meta.url);
3
3
  import {
4
4
  Options
5
- } from "./chunk-DUGGZ4EE.js";
5
+ } from "./chunk-RBNPBTDP.js";
6
6
  import {
7
7
  BUILTINS,
8
8
  debugString,
9
9
  escapeHtml,
10
10
  isoDay
11
- } from "./chunk-P2TRR6XK.js";
12
- import "./chunk-ERNVEZOK.js";
13
- import "./chunk-MDB3D3LP.js";
11
+ } from "./chunk-Z44IAMNG.js";
12
+ import "./chunk-2QTJTEBV.js";
13
+ import "./chunk-ERAIEV3O.js";
14
14
  import "./chunk-AD3HAW3W.js";
15
- import "./chunk-BXARVN5Z.js";
16
- import "./chunk-IOXCGMSF.js";
17
- import "./chunk-FVZ5JBRI.js";
15
+ import "./chunk-YCOTX2VM.js";
16
+ import "./chunk-GS5B3CBW.js";
17
+ import "./chunk-JC54PHIT.js";
18
18
  import {
19
19
  globSet
20
- } from "./chunk-DNWA7WNO.js";
20
+ } from "./chunk-HFSWUTXX.js";
21
+ import "./chunk-FVZ5JBRI.js";
21
22
  import "./chunk-UU43WIZG.js";
22
- import "./chunk-RFNLZM7W.js";
23
+ import "./chunk-IOBC665M.js";
23
24
  import "./chunk-CMUWRPSQ.js";
24
25
  import {
25
26
  bail,
26
27
  compareText,
27
- toDate
28
- } from "./chunk-JFPLNHEQ.js";
28
+ toDate,
29
+ warn,
30
+ warning
31
+ } from "./chunk-AIMEXBTK.js";
29
32
  import "./chunk-I3PS26CI.js";
30
33
 
31
34
  // src/modules/sitemap.ts
@@ -43,13 +46,12 @@ BUILTINS.set("ssqch/sitemap", (config, given) => {
43
46
  const o = new Options(given, ["url", "exclude", "lastmod", "output", "paginated", "alternates"]);
44
47
  const alternates = o.get("alternates");
45
48
  if (alternates !== void 0 && typeof alternates !== "function") bail(`alternates must be a function that gets each page and returns its translations, like (page) => [{ hreflang: "fr", href: "/fr/" }] (got ${typeof alternates})`);
46
- const url = o.string("url");
47
- if (url === void 0) bail(`url is required: the site's address, like "https://example.com"`);
49
+ const url = o.string("url") || void 0;
48
50
  const exclude = o.list("exclude") ?? [];
49
51
  const lastmod = o.bool("lastmod") ?? true;
50
52
  const output = o.string("output") ?? "/sitemap.xml";
51
53
  const paginated = o.bool("paginated") ?? false;
52
- if (!(url.startsWith("https://") || url.startsWith("http://"))) bail(`url must be the site's address, like "https://example.com" (got ${debugString(url)})`);
54
+ if (url !== void 0 && !(url.startsWith("https://") || url.startsWith("http://"))) bail(`url must be the site's address, like "https://example.com" (got ${debugString(url)})`);
53
55
  if (!output.startsWith("/") || output.endsWith("/")) bail(`output must be a URL path to a file, like "/sitemap.xml" (got ${debugString(output)})`);
54
56
  const matchers = exclude.map((glob) => {
55
57
  if (!glob.startsWith("/")) bail(`exclude: ${debugString(glob)} must be a URL path or glob starting with /, like "/tags/**"`);
@@ -57,7 +59,8 @@ BUILTINS.set("ssqch/sitemap", (config, given) => {
57
59
  });
58
60
  const excluded = (url2) => matchers.some((m) => m(url2));
59
61
  config.generators.push(["ssqch/sitemap", (config2, pages) => {
60
- const trimmed = url.replace(/\/+$/, "");
62
+ if (url === void 0) warn(warning("config", `sitemapPlugin() has no url, so ${output}'s <loc>s are paths from the site's root (as jekyll-sitemap writes them without one), and search engines read only whole addresses: give it the site's address, like { url: "https://example.com" }`));
63
+ const trimmed = (url ?? "").replace(/\/+$/, "");
61
64
  const withBase = trimmed.endsWith(config2.base) ? trimmed : trimmed + config2.base;
62
65
  const entries = [];
63
66
  const absolute = (href) => href.startsWith("/") ? withBase + href : href;
package/lib/ssqch.js CHANGED
@@ -6,15 +6,16 @@ import {
6
6
  files,
7
7
  markdown,
8
8
  readData,
9
+ safe,
9
10
  slugger,
10
11
  slugify
11
- } from "./chunk-IOXCGMSF.js";
12
+ } from "./chunk-JC54PHIT.js";
13
+ import "./chunk-HFSWUTXX.js";
12
14
  import "./chunk-FVZ5JBRI.js";
13
- import "./chunk-DNWA7WNO.js";
14
15
  import "./chunk-UU43WIZG.js";
15
- import "./chunk-RFNLZM7W.js";
16
+ import "./chunk-IOBC665M.js";
16
17
  import "./chunk-CMUWRPSQ.js";
17
- import "./chunk-JFPLNHEQ.js";
18
+ import "./chunk-AIMEXBTK.js";
18
19
  import "./chunk-I3PS26CI.js";
19
20
  export {
20
21
  api_default as default,
@@ -22,6 +23,7 @@ export {
22
23
  files,
23
24
  markdown,
24
25
  readData,
26
+ safe,
25
27
  slugger,
26
28
  slugify
27
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssqch",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "SiteSquatch (ssqch): a fast static site generator, configured with JavaScript",
5
5
  "keywords": [
6
6
  "static site generator",
package/types/index.d.ts CHANGED
@@ -52,16 +52,20 @@ export type Highlighter = ((code: string, lang: string) => Token[]) | string;
52
52
 
53
53
  /** How Markdown renders. */
54
54
  export interface MarkdownOptions {
55
- /** Automatic heading `id`s: `"github"` (the default: GitHub's and github-slugger's anchors, character for character), `"blackfriday"` (Hugo's older style: `a-b` for `A -- B`), or `false` for none. A `{#id}` on the heading always wins. */
56
- headingIds?: "github" | "blackfriday" | "ascii" | false | ((text: string) => string);
55
+ /** Automatic heading `id`s: `"github"` (the default: GitHub's and github-slugger's anchors, character for character), `"blackfriday"` (Hugo's older style: `a-b` for `A -- B`), `"kramdown"` (Jekyll's: GitHub's ids for the page's headings, and kramdown's ASCII ones, `section` for none, for headings inside `markdown="1"` HTML), `"markdown-it-anchor"` (that plugin's default: the lowercase text with spaces as `-`, percent-encoded, `what%E2%80%99s-new%3F`), `"python-markdown"` (MkDocs': Python-Markdown's `toc` ids, ASCII, `cafe-notes` for `Café notes`), or `false` for none. A `{#id}` on the heading always wins. */
56
+ headingIds?: "github" | "blackfriday" | "ascii" | "kramdown" | "markdown-it-anchor" | "python-markdown" | false | ((text: string) => string);
57
57
  /** `## Heading {#id .class key=value}`. Default `true`. */
58
58
  headingAttributes?: boolean;
59
59
  /** `[^1]` references, with the notes at the end of the page. Default `true`. */
60
60
  footnotes?: boolean;
61
61
  /** `- [ ]` and `- [x]` items. Default `true`. */
62
62
  taskLists?: boolean;
63
- /** Bare `https://` and `www.` URLs become links. Default `true`. */
64
- autolinks?: boolean;
63
+ /** Bare `https://` and `www.` URLs become links. `"fuzzy"` links bare domains (`example.com`, with a common or two-letter country TLD) and email addresses too, as markdown-it's `linkify` does. Default `true`. */
64
+ autolinks?: boolean | "fuzzy";
65
+ /** A single newline inside a paragraph (or a list item) becomes a `<br>`, as markdown-it's `breaks: true` makes it. Default `false`. */
66
+ breaks?: boolean;
67
+ /** An image (or a linked image) alone in a paragraph becomes `<figure><img alt=""><figcaption>its alt text</figcaption></figure>`, as markdown-it-implicit-figures with `figcaption: true` writes it. Default `false`. */
68
+ figures?: boolean;
65
69
  /** GitHub's `> [!NOTE]` alerts: note, tip, important, warning and caution. Default `true`. */
66
70
  alerts?: boolean;
67
71
  /** `::: name args` blocks, rendered by `_includes/containers/name.*`. Default `true`. */
@@ -72,8 +76,22 @@ export interface MarkdownOptions {
72
76
  smartPunctuation?: boolean;
73
77
  /** Lines indented four spaces are code blocks. `false` renders them as ordinary Markdown (HTML indented inside Markdown, say); fences are still code. Default `true`. */
74
78
  indentedCode?: boolean;
75
- /** Highlight fenced code at build time, with `hl-*` classes. The build writes their stylesheet to `/highlight.css`, or to `css` (a URL path), or not at all with `css: false`. `languages` adds languages or replaces built-in ones. Default `false`. */
76
- highlight?: boolean | { css?: string | false; languages?: Record<string, Highlighter> };
79
+ /** Link and image URLs are percent-encoded, as CommonMark's reference renderer writes them (`#كتابة` as `#%D9%83...`, `café.png` as `caf%C3%A9.png`). `false` writes them as the page has them, HTML-escaped only (`&` as `&amp;`), as kramdown (Jekyll) does; browsers go to the same place either way. A link or image hook gets the URL as written in both. Default `true`. */
80
+ encodeUrls?: boolean;
81
+ /** Highlight fenced code at build time, with `hl-*` classes. The build writes their stylesheet to `/highlight.css`, or to `css` (a URL path), or not at all with `css: false`. `languages` adds languages or replaces built-in ones. `classes` names the tokens as another highlighter does, so a site keeps its theme's CSS: `"prism"` (`token keyword`, `<pre class="language-js">`, marked lines as `<mark class="highlight-line highlight-line-active">`), `"pygments"` or `"chroma"` (Pygments' short names, `k`, `s`, `nf`, which MkDocs' and Hugo's themes style), or `{ keyword: "tok-keyword" }` for some kinds; the stylesheet uses the same names. Default `false`. */
82
+ /** Markdown inside HTML, as Jekyll's kramdown reads it: `"kramdown"` renders the content of an element with `markdown="1"` (span-level for `p`, headings and inline elements, block-level for the others; `"block"` and `"span"` choose) and drops the attribute, and keeps kramdown's HTML rules: a block-level element is raw HTML to its end tag, blank lines and all. Default `false`: HTML is CommonMark's, and Markdown inside it stays text. */
83
+ htmlMarkdown?: "kramdown" | false;
84
+ /** MkDocs' admonitions: `"mkdocs"` writes `!!! note "Title"` (body indented four spaces) as Python-Markdown's `<div class="admonition note"><p class="admonition-title">Title</p>...</div>`, and `??? note` and `???+ note` (pymdownx.details) as `<details class="note">`, open with `+`. The title is the type's name when there's none, and left out for `""`. Default `false`. */
85
+ admonitions?: "mkdocs" | false;
86
+ /** MkDocs' content tabs: `"mkdocs"` writes `=== "Tab"` blocks (body indented four spaces; tabs one after another are one set, `===+` selected, `===!` a new set) as pymdownx.tabbed's `alternate_style` writes them (`<div class="tabbed-set tabbed-alternate">`), which Material's CSS styles. Default `false`. */
87
+ tabs?: "mkdocs" | false;
88
+ /** Hugo's shortcodes: `"hugo"` reads a shortcode on a line of its own as a container: `{{< note type="tip" >}}` to `{{< /note >}}` (or `{{% %}}`) renders `_includes/containers/note.*` with `container.args`, `container.props` and the content as Markdown; one with no closing tag has no content. A shortcode inside a line of text is left as written. Default `false`. */
89
+ shortcodes?: "hugo" | false;
90
+ /** Links to `.md` files (`[Setup](setup/install.md#first)`) go to the page built from that file, with the `#` part: `true` writes its URL from the site's root (`/setup/install/#first`), `"relative"` from the page, as MkDocs does (`setup/install/#first`). A link to a file that isn't a page stays as written, for the link checker. Default `false`. */
91
+ sourceLinks?: boolean | "relative";
92
+ /** Another Markdown's ways, where they're CommonMark's otherwise. `"python-markdown"` (MkDocs'): a raw HTML block runs to its closing tag, blank lines and all; a list nests at four spaces (an item indented less is the next item); and the HTML is Python-Markdown's: `"` as it is in text, `<hr />`, `<br />`, `<img alt="" src="" />`, a tight item's nested list right after its text, nothing at the end. Default `false`. */
93
+ dialect?: "python-markdown" | false;
94
+ highlight?: boolean | { css?: string | false; languages?: Record<string, Highlighter>; classes?: "prism" | "pygments" | "chroma" | Partial<Record<TokenKind, string>> };
77
95
  }
78
96
 
79
97
  /** What a collection function gets. */
@@ -167,15 +185,15 @@ export interface ConfigParts {
167
185
  /** Shows up in error messages. */
168
186
  name?: string;
169
187
  /** Functions templates can call: `{{ slug(title) }}`. Async functions are awaited. */
170
- filters?: Record<string, (...args: any[]) => unknown>;
188
+ filters?: Record<string, (this: FilterContext | undefined, ...args: any[]) => unknown>;
171
189
  /** Data for every template. A value that's a function (sync or async) is called on each build, and its answer is that name's value. */
172
190
  data?: Record<string, unknown>;
173
191
  /** Custom collections, from the pages in collections. */
174
192
  collections?: Record<string, (pages: Pages) => unknown>;
175
193
  /** Run on every output file. Return the content, changed or not. */
176
194
  transforms?: Record<string, (content: string, page: TransformPage) => MaybePromise<string>>;
177
- /** Template engines of your own, by file extension: a function, or an object with `render`. Return the rendered text. */
178
- engines?: Record<string, EngineRender | { render: EngineRender }>;
195
+ /** Template engines of your own, by file extension: a function, or an object with `render` (a markdown-it instance is one: `render(source, env)` gets the page's data as `env`). Return the rendered text. `md` replaces ssqch's Markdown for `.md` files and `md` in a `render` chain, after the `markdownEngine`; the `markdown` filter stays ssqch's. `cache: true` keeps the page bodies it renders by their source, so a body with the same text isn't rendered again, in a build or the next one in `ssqch serve`: for an engine whose output depends on the source alone. */
196
+ engines?: Record<string, EngineRender | { render: EngineRender; cache?: boolean }>;
179
197
  /** Files or folders to copy: a path, or `{ from: to }`, or an array of them. */
180
198
  passthrough?: string | Record<string, string> | Array<string | Record<string, string>>;
181
199
  /** More paths for `ssqch serve` to watch. */
@@ -229,12 +247,22 @@ export interface Config extends ConfigParts {
229
247
  bundles?: boolean;
230
248
  /** Printing an undefined value (`{{ titel }}`) is an error, in every template language. Conditionals and defaults still work. Default `false`. */
231
249
  strict?: boolean;
250
+ /** Start a template's body at its first line with text, dropping the blank lines after the closing `---`, as Jekyll does (its layouts and includes print no blank line there). Off by default: the body starts on the line after `---`, as Eleventy and gray-matter have it. */
251
+ trimAfterFrontMatter?: boolean;
252
+ /** Templates see Jekyll's `page` and `site`, so a Jekyll site's layouts and includes run as written: `page` has the page's front matter too (`page.title`; ssqch's own keys, like `url` and `date`, win) and `page.path` and `page.categories`; `site` has the site's own keys, `posts` (newest first), each collection by its tag (`site.articles`), `pages`, `html_pages`, `categories`, `tags`, `data` (the global data) and `time`; and their items read in Jekyll's shape (`post.title`, `post.content`, `post.excerpt`). Off by default: front matter is at the top level (`title`) and items keep it under `data`. */
253
+ jekyllTemplates?: boolean;
254
+ /** Templates see what MkDocs gives a theme's, so an MkDocs theme's Jinja templates (Material for MkDocs') run as written: `config` (mkdocs.yml, with the theme's `mkdocs_theme.yml` under its `theme`), `nav` (Sections, Pages and Links, with `active` on the page being rendered), `page` in a layout (MkDocs' page: `title`, `url` without its first `/`, `abs_url`, `canonical_url`, `edit_url`, `content`, `toc`, `meta`, `previous_page`, `next_page`, `ancestors`, `is_homepage`), `base_url`, `mkdocs_version` and `build_date_utc`, and the `url` and `script_tag` filters, relative to the page. A Markdown page's layout is `main.html` (or its front matter's `template`), the theme's `404.html` makes `/404.html`, and Jinja doesn't escape (`jinja: { autoescape }` says otherwise). `true` reads `mkdocs.yml`; a string names another file. Off by default. */
255
+ mkdocsTemplates?: boolean | string;
256
+ /** Jinja's settings for `.jinja` and `.j2` templates. `autoescape: false` prints values as they are, as MkDocs' Jinja does (`| e` still escapes); default `true`, or `false` with `mkdocsTemplates`. `.njk` always escapes. */
257
+ jinja?: { autoescape?: boolean };
232
258
  /** `page.lastModified`: `"git"` for the last commit that changed the page's file (its modification time when it has uncommitted changes), or `"file"` for the modification time. Off by default. Needs the full history in CI (`fetch-depth: 0`). */
233
259
  lastModified?: "git" | "file" | false;
234
260
  /** The date of a page with no date of its own (in its data or its file name): `"git"` for the last commit that changed its file, the same in every checkout, or `"file"` (the default) for the file's modification time, which is when the checkout wrote it. Either way it sorts after the dated pages, by path. Needs the full history in CI (`fetch-depth: 0`). */
235
261
  dateFallback?: "git" | "file";
236
262
  /** The time zone the site's own JavaScript runs in, as an IANA name (`"UTC"`, `"America/New_York"`): `Date`'s local methods and libraries like luxon and date-fns, in data files, filters, hooks and Edge templates, so a laptop and CI build the same pages. ssqch's own date filters are UTC whatever this says. Default: the machine's. The config's own top-level code runs before it applies. */
237
263
  timeZone?: string;
264
+ /** Other names for layouts: `{ post: "layouts/post.njk" }` makes `layout: post` that file (where it would be `_includes/post.*`), as Eleventy's `addLayoutAlias` did. A page's `layout` is still the name it gave. */
265
+ layoutAliases?: Record<string, string>;
238
266
  /** The path the site is served under, when that isn't the root of its domain: `"/repo/"` for `https://you.github.io/repo/`. Templates and `page.url` stay as they are; ssqch adds the base to URLs from the site's root in the HTML it writes. Use the `withBase()` filter outside HTML attributes. */
239
267
  base?: string;
240
268
  /** A theme under the site: a folder (`"themes/docs"`), or a git repository pinned to a tag or a commit's full hash (`"https://github.com/you/theme#v1.2.0"`, with `#v1.2.0:folder` for a theme in a folder of its repository), fetched once and kept in `.cache/ssqch/themes/`. The site's own includes, data, pages and files win over the theme's, one by one. In a list, earlier themes sit on top of later ones. */
@@ -252,10 +280,19 @@ export interface Config extends ConfigParts {
252
280
 
253
281
  /** Returns its argument. It's there so the config reads as one, and for these types. */
254
282
  export function defineConfig<T extends Config | ((context: ConfigContext) => MaybePromise<Config>)>(config: T): T;
255
- /** Render Markdown with the site's `markdown` options (render hooks and containers are for templates). `inline` drops the `<p>` around a single paragraph. */
256
- export function markdown(text: string, options?: { inline?: boolean }): string;
283
+ /** Render Markdown with the site's `markdown` options (render hooks and containers are for templates). `inline` drops the `<p>` around a single paragraph: `markdown(text, { inline: true })`, or `markdown(text, "inline")` as in templates. */
284
+ export function markdown(text: string, options?: { inline?: boolean } | "inline"): string;
257
285
  /** Read a JSON, YAML or TOML file (from the project root) into data: `readData("src/_data/sites/en.yml")`. */
258
286
  export function readData(path: string): any;
287
+ /** HTML that templates print as it is, in every template language: a filter's answer that's markup, `return safe(`<b>${text}</b>`)`. Anything else gets the text as a string. Escape what goes in it yourself. */
288
+ export function safe(html: unknown): string;
289
+ /** `this` in a config filter written as a `function` (an arrow function has no `this`): the page being rendered. `undefined` outside a render (in a collection, a data file or a hook). */
290
+ export interface FilterContext {
291
+ /** The page being rendered, as its templates see `page`: `url`, `inputPath`, `outputPath`, `date`, and in a layout `headings` and `excerpt`. */
292
+ page: Record<string, any>;
293
+ /** Everything the template sees: front matter, the cascade, `collections`, and in a layout `content`. */
294
+ data: Record<string, any>;
295
+ }
259
296
  /** A file that `files()` found. */
260
297
  export interface FoundFile {
261
298
  /** From the project root, with `/`: `"images/albums/v1/20011222_08.JPG"`. */
@@ -287,6 +324,10 @@ export interface SlugifyOptions {
287
324
  separator?: string;
288
325
  /** `"drop"` (the default): `Drew's Brownies` is `drews-brownies`. `"separate"`: an apostrophe splits words like other punctuation, `drew-s-brownies`, to keep a site's existing URLs. */
289
326
  apostrophes?: "drop" | "separate";
327
+ /** `true` takes accents off and spells out a few letters and symbols first, as the slugify package does: `Thomas Sjögren` is `thomas-sjogren`, `Straße & 50%` is `strasse-and-50-percent`. Other scripts stay as they are. Default `false`. */
328
+ ascii?: boolean;
329
+ /** `true` drops HTML tags first: `Use <code>title</code>` is `use-title`, not `use-code-title-code`. Default `false`. */
330
+ stripTags?: boolean;
290
331
  }
291
332
  /** The `slugify` template filter, for data files: `slugify("Taco Bake", { separator: "_" })` is `"taco_bake"`. Lowercase letters and digits, with `separator` (a dash by default) for each run of anything else. A string is the separator. */
292
333
  export function slugify(text: string, options?: SlugifyOptions | string): string;
package/types/minify.d.ts CHANGED
@@ -9,11 +9,23 @@ export interface MinifyOptions {
9
9
  removeComments?: boolean;
10
10
  /** Default `true`. */
11
11
  shortDoctype?: boolean;
12
- /** Drop boolean attributes' values (`defer="defer"` to `defer`) and extra whitespace in `class`, `srcset`, URLs and the viewport `<meta>`. Default `true`. */
12
+ /** Drop boolean attributes' values (`defer="defer"` to `defer`) and extra whitespace in `class`, `srcset`, URLs and the viewport `<meta>` (whose numbers it writes as html-minifier-terser does: `initial-scale=1`). Default `true`. */
13
13
  shortenAttributes?: boolean;
14
14
  }
15
15
 
16
- /** Minifies HTML output, after the image transform, with ssqch's own minifier (Rust, as WebAssembly): it doesn't write html-minifier-terser's bytes. */
17
- export function minifyPlugin(options?: MinifyOptions): BuiltinPlugin;
16
+ /** `minifyPlugin()`'s options: the minifier's, and what else it minifies, all off by default. */
17
+ export interface MinifyPluginOptions extends MinifyOptions {
18
+ /** Compress each page's `<style>` elements with ssqch's Sass, as `minifyCss` does; one it can't read (Sass syntax, native CSS nesting) stays as it is, with a warning. Default `false`. */
19
+ css?: boolean;
20
+ /** Take the whitespace between tags out of `.xml`, `.rss` and `.atom` files (feeds, sitemaps), not inside text, CDATA or comments. Default `false`. */
21
+ xml?: boolean;
22
+ /** Write `.json` and `.webmanifest` files without spaces. Default `false`. */
23
+ json?: boolean;
24
+ }
25
+
26
+ /** Minifies HTML output, after the image transform, with ssqch's own minifier (Rust, as WebAssembly): it doesn't write html-minifier-terser's bytes. With `css`, `xml` and `json`, inline CSS, feeds and manifests too. */
27
+ export function minifyPlugin(options?: MinifyPluginOptions): BuiltinPlugin;
18
28
  /** Minify one string of HTML, with the plugin's options. */
19
29
  export function minify(html: string, options?: MinifyOptions): string;
30
+ /** Compress CSS text as `style: "compressed"` Sass writes it (`.a{color:#fff}`), for CSS inlined by a template: `{{ css | minifyCss }}` in a filter of your own. Sass's own syntax, and CSS ssqch's Sass can't read (native nesting), is an error. */
31
+ export function minifyCss(css: string): string;
package/types/sass.d.ts CHANGED
@@ -9,6 +9,8 @@ export interface SassPluginOptions {
9
9
  style?: "compressed" | "expanded";
10
10
  /** More folders `@use` and `@import` look in, relative to the project root. */
11
11
  loadPaths?: string[];
12
+ /** `false` leaves out what CSS with a character outside ASCII starts with: a byte order mark (compressed) or `@charset "UTF-8";` (expanded), as Dart Sass's `--no-charset` does and jekyll-sass-converter's output has it. Default `true`. */
13
+ charset?: boolean;
12
14
  }
13
15
 
14
16
  /** Compiles Sass at the start of each build, with grass (Rust, as WebAssembly: no Dart Sass), so fingerprinting and the link checker see the CSS. */
@@ -3,8 +3,8 @@
3
3
  import type { BuiltinPlugin } from "ssqch";
4
4
 
5
5
  export interface SitemapPluginOptions {
6
- /** The site's address, like `"https://example.com"`. */
7
- url: string;
6
+ /** The site's address, like `"https://example.com"`. Without one (or with `""`, as a Jekyll site's `url` often is), each `<loc>` is a path from the site's root, as jekyll-sitemap writes it, and every build warns: search engines read only whole addresses. */
7
+ url?: string;
8
8
  /** URL globs to leave out, like `["/tags/**"]`. Pages with `sitemap: false` and 404 pages are always left out. */
9
9
  exclude?: string[];
10
10
  /** Add `<lastmod>` from each page's date. Default `true`. */
Binary file
package/wasm/minify.wasm CHANGED
Binary file
package/wasm/sass.wasm CHANGED
Binary file