ssqch 0.8.0 → 0.10.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 (87) hide show
  1. package/README.md +3 -1
  2. package/bundled/docs/agents.md +70 -0
  3. package/bundled/docs/benchmarks.md +29 -0
  4. package/bundled/docs/build-summary.md +27 -0
  5. package/bundled/docs/comparing-builds.md +51 -0
  6. package/bundled/docs/configuring.md +138 -0
  7. package/bundled/docs/content-schemas.md +54 -0
  8. package/bundled/docs/css-and-javascript.md +33 -0
  9. package/bundled/docs/data-files.md +55 -0
  10. package/bundled/docs/deploying.md +47 -0
  11. package/bundled/docs/field-guide.md +144 -0
  12. package/bundled/docs/footprint.md +27 -0
  13. package/bundled/docs/github-pages.md +41 -0
  14. package/bundled/docs/index.md +26 -0
  15. package/bundled/docs/install.md +27 -0
  16. package/bundled/docs/known-gaps.md +18 -0
  17. package/bundled/docs/markdown.md +114 -0
  18. package/bundled/docs/multilingual.md +14 -0
  19. package/bundled/docs/nav.yml +50 -0
  20. package/bundled/docs/netlify.md +30 -0
  21. package/bundled/docs/new-pages.md +42 -0
  22. package/bundled/docs/plugins.md +13 -0
  23. package/bundled/docs/rust-plugins.md +32 -0
  24. package/bundled/docs/seo.md +19 -0
  25. package/bundled/docs/template-languages.md +106 -0
  26. package/bundled/docs/templates.md +37 -0
  27. package/bundled/docs/themes.md +31 -0
  28. package/bundled/{trailheads → docs/trailheads}/from-component-frameworks.md +7 -3
  29. package/bundled/{trailheads → docs/trailheads}/from-docusaurus.md +7 -4
  30. package/bundled/{trailheads → docs/trailheads}/from-eleventy.md +7 -4
  31. package/bundled/{trailheads → docs/trailheads}/from-hexo.md +7 -4
  32. package/bundled/docs/trailheads/from-jekyll.md +82 -0
  33. package/bundled/{trailheads → docs/trailheads}/from-mkdocs.md +8 -5
  34. package/bundled/{trailheads → docs/trailheads}/from-zola.md +6 -3
  35. package/bundled/docs/trailheads.md +38 -0
  36. package/bundled/docs/where-values-come-from.md +57 -0
  37. package/bundled/ssqch.d.ts +20 -10
  38. package/lib/assets.js +15 -7
  39. package/lib/{chunk-N5QTGQ5N.js → chunk-2LEOPLTZ.js} +2 -2
  40. package/lib/{chunk-AMBFWPZ4.js → chunk-3EPHKJEG.js} +3 -3
  41. package/lib/{chunk-BRK4MXXO.js → chunk-3HHRKG33.js} +65 -18
  42. package/lib/{chunk-EIT4ZDT4.js → chunk-5DNDSNTP.js} +61 -5
  43. package/lib/{chunk-NUKCUDC4.js → chunk-7HXCQEGA.js} +3 -3
  44. package/lib/{chunk-6XYSFG6V.js → chunk-BGCBSQ4A.js} +3067 -3054
  45. package/lib/{chunk-RI2L3VGO.js → chunk-CB6YFUXU.js} +19 -11
  46. package/lib/{chunk-JSPSMIJ2.js → chunk-DMVJ53SM.js} +9 -9
  47. package/lib/{chunk-FYGE634X.js → chunk-DW7VMJEZ.js} +9 -9
  48. package/lib/{chunk-GSKVRAHF.js → chunk-E5UB2YY7.js} +6 -6
  49. package/lib/{chunk-DHHQKW4F.js → chunk-EEJDLCD3.js} +7 -7
  50. package/lib/{chunk-TWCVHOKO.js → chunk-HDQ4SRWM.js} +125 -4
  51. package/lib/{chunk-JRT7TQQP.js → chunk-HGJ5VWUR.js} +1 -1
  52. package/lib/{chunk-C35KIPAR.js → chunk-JWCCVTTR.js} +98 -7
  53. package/lib/{chunk-EZZUUPI4.js → chunk-JXZT5L7W.js} +2 -2
  54. package/lib/{chunk-KBGE5MCY.js → chunk-LAV3DEY4.js} +1 -1
  55. package/lib/{chunk-IRHRK7XB.js → chunk-LCPSKHAV.js} +1 -1
  56. package/lib/{chunk-3PHCFZEU.js → chunk-N4O5MDIB.js} +2 -2
  57. package/lib/{chunk-TDGBQNGW.js → chunk-NFJJKDRI.js} +1 -1
  58. package/lib/{chunk-UGEGUUBT.js → chunk-NUUEOGLZ.js} +8 -8
  59. package/lib/{chunk-VVPZ5PDP.js → chunk-Q4LFTYK2.js} +11 -11
  60. package/lib/{chunk-TN6EEDX2.js → chunk-QMA7CK7B.js} +51 -6
  61. package/lib/{chunk-CDEPYU7W.js → chunk-RJFWTW2Y.js} +2 -2
  62. package/lib/{chunk-YSH2NMIE.js → chunk-RKFZSVNF.js} +6 -6
  63. package/lib/{chunk-GOE4ZSAB.js → chunk-RM5Q3KFB.js} +9 -9
  64. package/lib/{chunk-37KSIVNY.js → chunk-RVBNVGZV.js} +3 -3
  65. package/lib/{chunk-HR2RU2LY.js → chunk-SA5KSJ4Y.js} +11 -7
  66. package/lib/{chunk-BOBPVAX2.js → chunk-SRNLKWXL.js} +424 -78
  67. package/lib/{chunk-WP3RPVUM.js → chunk-Y2ESFAAD.js} +2 -3
  68. package/lib/{chunk-WMOVCQO6.js → chunk-ZM6TU2JB.js} +6 -6
  69. package/lib/cli.js +32 -25
  70. package/lib/elements.js +7 -7
  71. package/lib/image.js +8 -8
  72. package/lib/links.js +10 -10
  73. package/lib/minify.js +7 -7
  74. package/lib/redirects.js +8 -8
  75. package/lib/rss.js +20 -19
  76. package/lib/sass.js +45 -10
  77. package/lib/sitemap.js +36 -11
  78. package/lib/ssqch.js +4 -4
  79. package/package.json +2 -2
  80. package/types/image.d.ts +5 -5
  81. package/types/index.d.ts +12 -4
  82. package/types/rss.d.ts +1 -1
  83. package/types/sitemap.d.ts +2 -0
  84. package/wasm/markdown.wasm +0 -0
  85. package/bundled/README.md +0 -1247
  86. package/lib/{chunk-6XYSFG6V.js.LEGAL.txt → chunk-BGCBSQ4A.js.LEGAL.txt} +3 -3
  87. /package/lib/{chunk-BOBPVAX2.js.LEGAL.txt → chunk-SRNLKWXL.js.LEGAL.txt} +0 -0
@@ -75,7 +75,7 @@ declare module "ssqch" {
75
75
 
76
76
  /** How Markdown renders. */
77
77
  export interface MarkdownOptions {
78
- /** Automatic heading `id`s: `"github"` (the default), `"blackfriday"` (Hugo's older style: `a-b` for `A -- B`), or `false` for none. A `{#id}` on the heading always wins. */
78
+ /** 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. */
79
79
  headingIds?: "github" | "blackfriday" | "ascii" | false | ((text: string) => string);
80
80
  /** `## Heading {#id .class key=value}`. Default `true`. */
81
81
  headingAttributes?: boolean;
@@ -123,6 +123,10 @@ declare module "ssqch" {
123
123
  export interface BuildEvent {
124
124
  env: "production" | "development";
125
125
  serving: boolean;
126
+ /** The build was run with `--quiet`: print only warnings and errors. */
127
+ quiet: boolean;
128
+ /** The build was run with `--verbose`. */
129
+ verbose: boolean;
126
130
  /** Folders relative to the project root, like `./src/`. */
127
131
  dirs: { input: string; output: string; includes: string; data: string };
128
132
  /** The files the build wrote (`afterBuild` only). */
@@ -130,7 +134,7 @@ declare module "ssqch" {
130
134
  }
131
135
 
132
136
  type MaybePromise<T> = T | Promise<T>;
133
- /** A function, or `{ run: "command" }` to run a program in the project root (through `sh -c`, or `cmd /C` on Windows). It gets `SSQCH_ENV`, `SSQCH_SERVING`, `SSQCH_INPUT` and `SSQCH_OUTPUT`; a failure fails the build. */
137
+ /** A function, or `{ run: "command" }` to run a program in the project root (through `sh -c`, or `cmd /C` on Windows). It gets `SSQCH_ENV`, `SSQCH_SERVING`, `SSQCH_QUIET`, `SSQCH_INPUT` and `SSQCH_OUTPUT`; a failure fails the build. */
134
138
  type Hook = ((event: BuildEvent) => MaybePromise<void>) | { run: string };
135
139
  /** Renders a template's body (front matter removed) with the page's data. */
136
140
  type EngineRender = (source: string, data: Record<string, any>) => MaybePromise<string>;
@@ -182,7 +186,7 @@ declare module "ssqch" {
182
186
  name?: string;
183
187
  /** Functions templates can call: `{{ slug(title) }}`. Async functions are awaited. */
184
188
  filters?: Record<string, (...args: any[]) => unknown>;
185
- /** Data for every template. A function (sync or async) is called on each build. */
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. */
186
190
  data?: Record<string, unknown>;
187
191
  /** Custom collections, from the pages in collections. */
188
192
  collections?: Record<string, (pages: Pages) => unknown>;
@@ -245,6 +249,10 @@ declare module "ssqch" {
245
249
  strict?: boolean;
246
250
  /** `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`). */
247
251
  lastModified?: "git" | "file" | false;
252
+ /** 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`). */
253
+ dateFallback?: "git" | "file";
254
+ /** 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. */
255
+ timeZone?: string;
248
256
  /** 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. */
249
257
  base?: string;
250
258
  /** 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. */
@@ -255,7 +263,7 @@ declare module "ssqch" {
255
263
  budgets?: Partial<Record<"pages" | "images" | "css" | "javascript" | "fonts" | "media" | "documents" | "data" | "other" | "total", number | string>>;
256
264
  /** What `ssqch serve` runs besides the server. (The server builds in a process of its own, starts it again when the config or a module it imports changes, and listens on 127.0.0.1 only.) */
257
265
  serve?: {
258
- /** Programs to start with the server and stop with it, like the watchers of your CSS and JavaScript tools: `["npx postcss src/app.css -o dist/app.css --watch"]`. Their output is shown with the tool's name in front. Builds don't run them. */
266
+ /** Programs to start with the server and stop with it, like the watchers of your CSS and JavaScript tools: `["npx postcss src/app.css -o dist/app.css --watch"]`. Their output is shown with the tool's name in front. They get `SSQCH_ENV`, `SSQCH_SERVING` (`true`), `SSQCH_QUIET`, `SSQCH_INPUT` and `SSQCH_OUTPUT`, as build commands do. Builds don't run them. */
259
267
  run?: string | string[];
260
268
  };
261
269
  }
@@ -324,13 +332,13 @@ declare module "ssqch/image" {
324
332
  outputDir?: string;
325
333
  /** URL path they're served from. Default `/img/`. */
326
334
  urlPath?: string;
327
- /** WebP quality, sharp's: a whole number from 1 to 100. Default 75 (0.7's 75 too: WebP's numbers didn't change). */
335
+ /** WebP quality, sharp's: a whole number from 1 to 100. Default 75. */
328
336
  webpQuality?: number;
329
- /** AVIF quality, sharp's: a whole number from 1 to 100. Default 41, which looks like 0.7's default of 50 (0.7's 60 is 48; the changelog has the table). */
337
+ /** AVIF quality, sharp's: a whole number from 1 to 100. Default 41. */
330
338
  avifQuality?: number;
331
- /** sharp's AVIF effort: a whole number from 0 (fastest) to 9 (slowest, smallest files). Default 2. Replaces 0.7's `avifSpeed`: speed 8 is effort 2, speed 4 is effort 3. */
339
+ /** sharp's AVIF effort: a whole number from 0 (fastest) to 9 (slowest, smallest files). Default 2. */
332
340
  avifEffort?: number;
333
- /** JPEG quality, sharp's (mozjpeg): a whole number from 1 to 100. Default 89, which looks like 0.7's default of 80. */
341
+ /** JPEG quality, sharp's (mozjpeg): a whole number from 1 to 100. Default 89. */
334
342
  jpegQuality?: number;
335
343
  /** A width larger than the original is clamped to it only when the width before it is this many times smaller. Default 1.25. */
336
344
  minimumThreshold?: number;
@@ -359,7 +367,7 @@ declare module "ssqch/image" {
359
367
  size: number;
360
368
  }
361
369
 
362
- /** Turns every local `<img>` in HTML output into a `<picture>`, encoded by sharp (AVIF needs no build feature). `[ssqch] Encoded ...` lines come as each image's files are done, while pages go on rendering. */
370
+ /** Turns every local `<img>` in HTML output into a `<picture>`, with AVIF, WebP and fallback sources encoded by sharp. `[ssqch] Encoded ...` lines come as each image's files are done, while pages go on rendering. */
363
371
  export function imagePlugin(options?: ImagePluginOptions): BuiltinPlugin;
364
372
 
365
373
  /** Generate one image's files with the plugin's settings and cache. Keyed by format, smallest first; with `"auto"` in `formats`, its files are under `auto` too. */
@@ -401,7 +409,7 @@ declare module "ssqch/rss" {
401
409
  export function dateToRfc3339(date: Date | string): string;
402
410
  /** A date as RFC 822 (`Sat, 01 Jun 2024 00:00:00 +0000`), for RSS feeds. */
403
411
  export function dateToRfc822(date: Date | string): string;
404
- /** A URL made absolute against the site's address: `absoluteUrl(post.url, "https://example.com")`. */
412
+ /** A URL made absolute against the site's address: `absoluteUrl(post.url, "https://example.com")`. As a template filter, it puts the site's `base` in front of a URL from the root that doesn't have it yet; called from code, it resolves as `new URL(url, base)` does. */
405
413
  export function absoluteUrl(url: string, base: string): string;
406
414
  /** Every link and image in some HTML made absolute, for a feed's content. */
407
415
  export function htmlToAbsoluteUrls(html: string, base: string): string;
@@ -477,6 +485,8 @@ declare module "ssqch/sitemap" {
477
485
  output?: string;
478
486
  /** List every page of a list split into pages (`/2/`, `/3/`), not just the first. Pagination with `size: 1` (a page per tag, say) is always listed. Default `false`. */
479
487
  paginated?: boolean;
488
+ /** A page's translations, as `<xhtml:link rel="alternate" hreflang>` links under its `<loc>` (Google's way to list them): a function that gets each page (`url`, `inputPath`, `outputPath`, `date`, `data`) and returns `[{ hreflang: "fr", href: "/fr/guide/" }]`, the page itself included, or nothing. An `href` from the site's root gets the `url` and `base` in front. It's called at once, for each page in the sitemap. */
489
+ alternates?: (page: { url: string; inputPath: string; outputPath: string; date: Date; data: Record<string, any> }) => Array<{ hreflang: string; href: string }> | undefined | null;
480
490
  }
481
491
 
482
492
  /** Writes `sitemap.xml` listing every HTML page. */
package/lib/assets.js CHANGED
@@ -2,27 +2,27 @@ import { createRequire as __ssqchCreateRequire } from "node:module";
2
2
  const require = __ssqchCreateRequire(import.meta.url);
3
3
  import {
4
4
  Options
5
- } from "./chunk-JRT7TQQP.js";
5
+ } from "./chunk-HGJ5VWUR.js";
6
6
  import {
7
7
  BUILTINS,
8
8
  blake3Hex,
9
9
  rewriteHtml
10
- } from "./chunk-TN6EEDX2.js";
11
- import "./chunk-IRHRK7XB.js";
10
+ } from "./chunk-QMA7CK7B.js";
11
+ import "./chunk-LCPSKHAV.js";
12
12
  import "./chunk-NKXEPHRZ.js";
13
13
  import "./chunk-AD3HAW3W.js";
14
14
  import "./chunk-DDV6JEC2.js";
15
- import "./chunk-EIT4ZDT4.js";
15
+ import "./chunk-5DNDSNTP.js";
16
16
  import "./chunk-FVZ5JBRI.js";
17
- import "./chunk-TDGBQNGW.js";
17
+ import "./chunk-NFJJKDRI.js";
18
18
  import "./chunk-UU43WIZG.js";
19
- import "./chunk-C35KIPAR.js";
19
+ import "./chunk-JWCCVTTR.js";
20
20
  import "./chunk-CMUWRPSQ.js";
21
21
  import {
22
22
  bail,
23
23
  warn,
24
24
  warning
25
- } from "./chunk-6XYSFG6V.js";
25
+ } from "./chunk-BGCBSQ4A.js";
26
26
  import {
27
27
  displayPath
28
28
  } from "./chunk-VJWQSYEG.js";
@@ -167,6 +167,7 @@ BUILTINS.set("ssqch/assets", (config, given) => {
167
167
  let sri = /* @__PURE__ */ new Map();
168
168
  let names = [];
169
169
  let changing = [];
170
+ let renamed = [];
170
171
  config.beforeBuild.push({ label: "", fn: () => {
171
172
  const output = path.resolve(config.root, config.output);
172
173
  const shownOutput = displayPath(config.root, output);
@@ -174,6 +175,8 @@ BUILTINS.set("ssqch/assets", (config, given) => {
174
175
  const map = /* @__PURE__ */ new Map();
175
176
  const hashes = /* @__PURE__ */ new Map();
176
177
  const done = [];
178
+ for (const plain of renamed) config.renamedCopies.delete(plain);
179
+ renamed = [];
177
180
  for (const file of files) {
178
181
  if (enabled) {
179
182
  const src = passthroughSource(config, file);
@@ -187,6 +190,11 @@ BUILTINS.set("ssqch/assets", (config, given) => {
187
190
  }
188
191
  }
189
192
  const hashed = fingerprint(output, file);
193
+ if (src !== void 0) {
194
+ const plain = path.join(output, file.replace(/^\/+/, ""));
195
+ config.renamedCopies.set(plain, path.join(output, hashed.replace(/^\/+/, "")));
196
+ renamed.push(plain);
197
+ }
190
198
  if (withIntegrity) {
191
199
  const at = path.join(output, hashed.replace(/^\/+/, ""));
192
200
  let bytes;
@@ -3,7 +3,7 @@ const require = __ssqchCreateRequire(import.meta.url);
3
3
  import {
4
4
  warn,
5
5
  warning
6
- } from "./chunk-6XYSFG6V.js";
6
+ } from "./chunk-BGCBSQ4A.js";
7
7
  import {
8
8
  compareText,
9
9
  realPath
@@ -84,7 +84,7 @@ async function settled(files) {
84
84
  return last;
85
85
  }
86
86
  function missingMessage(url, tools, output) {
87
- if (tools.length === 0) return `${url} is linked but nothing wrote it to ${output}. If a tool makes it, run its watcher with \`serve.run\` (see "CSS and JavaScript" in the README)`;
87
+ if (tools.length === 0) return `${url} is linked but nothing wrote it to ${output}. If a tool makes it, run its watcher with \`serve.run\` (\`ssqch docs "CSS and JavaScript"\`)`;
88
88
  if (tools.length === 1) return `${url} is linked but isn't in ${output}: serve.run's ${tools[0]} hasn't written it (its output is in the terminal)`;
89
89
  return `${url} is linked but isn't in ${output}: none of serve.run's ${tools.slice(0, -1).join(", ")} or ${tools[tools.length - 1]} has written it (their output is in the terminal)`;
90
90
  }
@@ -2,11 +2,11 @@ import { createRequire as __ssqchCreateRequire } from "node:module";
2
2
  const require = __ssqchCreateRequire(import.meta.url);
3
3
  import {
4
4
  starterEngines
5
- } from "./chunk-WP3RPVUM.js";
5
+ } from "./chunk-Y2ESFAAD.js";
6
6
  import {
7
7
  DEFAULTS,
8
8
  configOptions
9
- } from "./chunk-TN6EEDX2.js";
9
+ } from "./chunk-QMA7CK7B.js";
10
10
  import {
11
11
  VERSION
12
12
  } from "./chunk-AD3HAW3W.js";
@@ -15,7 +15,7 @@ import {
15
15
  } from "./chunk-DDV6JEC2.js";
16
16
  import {
17
17
  red
18
- } from "./chunk-6XYSFG6V.js";
18
+ } from "./chunk-BGCBSQ4A.js";
19
19
 
20
20
  // src/commands/capabilities.ts
21
21
  var MODULE_EXPORTS = [
@@ -2,10 +2,10 @@ import { createRequire as __ssqchCreateRequire } from "node:module";
2
2
  const require = __ssqchCreateRequire(import.meta.url);
3
3
  import {
4
4
  modules
5
- } from "./chunk-AMBFWPZ4.js";
5
+ } from "./chunk-3EPHKJEG.js";
6
6
  import {
7
7
  BUILTIN_FILTERS
8
- } from "./chunk-RI2L3VGO.js";
8
+ } from "./chunk-CB6YFUXU.js";
9
9
  import {
10
10
  longHelp
11
11
  } from "./chunk-F65YUXZ7.js";
@@ -14,38 +14,72 @@ import {
14
14
  bundled,
15
15
  bundledNames,
16
16
  types
17
- } from "./chunk-WP3RPVUM.js";
17
+ } from "./chunk-Y2ESFAAD.js";
18
18
  import {
19
19
  configOptions
20
- } from "./chunk-TN6EEDX2.js";
21
- import "./chunk-IRHRK7XB.js";
20
+ } from "./chunk-QMA7CK7B.js";
21
+ import "./chunk-LCPSKHAV.js";
22
22
  import "./chunk-NKXEPHRZ.js";
23
23
  import {
24
24
  VERSION
25
25
  } from "./chunk-AD3HAW3W.js";
26
26
  import "./chunk-DDV6JEC2.js";
27
- import "./chunk-EIT4ZDT4.js";
27
+ import "./chunk-5DNDSNTP.js";
28
28
  import {
29
29
  closest
30
30
  } from "./chunk-FVZ5JBRI.js";
31
- import "./chunk-TDGBQNGW.js";
31
+ import "./chunk-NFJJKDRI.js";
32
32
  import "./chunk-UU43WIZG.js";
33
- import "./chunk-C35KIPAR.js";
33
+ import "./chunk-JWCCVTTR.js";
34
34
  import "./chunk-CMUWRPSQ.js";
35
35
  import {
36
36
  OTHER_CONFIGS,
37
37
  TABLE,
38
+ jsYaml,
38
39
  red,
39
40
  toJson
40
- } from "./chunk-6XYSFG6V.js";
41
+ } from "./chunk-BGCBSQ4A.js";
41
42
  import "./chunk-VJWQSYEG.js";
42
43
  import "./chunk-I3PS26CI.js";
43
44
 
44
45
  // src/commands/docs.ts
45
- var GUIDES_URL = "https://github.com/reverentgeek/sitesquatch/blob";
46
+ var SITE_URL = "https://sitesquatch.dev";
47
+ function docsPage(text) {
48
+ const front = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
49
+ const data = front ? jsYaml.load(front[1]) ?? {} : {};
50
+ return { title: String(data.title ?? ""), body: front ? text.slice(front[0].length) : text };
51
+ }
52
+ function headingsDown(body) {
53
+ let fence = null;
54
+ return body.split(/\r?\n/).map((line) => {
55
+ const trimmed = line.trimStart();
56
+ const marker = ["```", "~~~"].find((m) => trimmed.startsWith(m));
57
+ if (marker !== void 0) {
58
+ if (fence === null) fence = marker;
59
+ else if (fence === marker && trimmed.trimEnd().replace(new RegExp(`^\\${marker[0]}+`), "") === "") fence = null;
60
+ return line;
61
+ }
62
+ return fence === null && /^#{1,5} /.test(line) ? `#${line}` : line;
63
+ }).join("\n");
64
+ }
65
+ function docsText() {
66
+ const nav = jsYaml.load(bundled("docs/nav.yml")) ?? [];
67
+ const files = nav.flatMap((group) => group.pages).filter((p) => typeof p === "string" && !p.startsWith("trailheads/"));
68
+ return files.map((file, i) => {
69
+ const { title, body } = docsPage(bundled(`docs/${file}`));
70
+ return i === 0 ? `# ${title}
71
+
72
+ ${body.trim()}
73
+ ` : `## ${title}
74
+
75
+ ${headingsDown(body).trim()}
76
+ `;
77
+ }).join("\n");
78
+ }
46
79
  var byteLength = (text) => Buffer.byteLength(text);
47
80
  var ALNUM = /[\p{Alphabetic}\p{N}]/u;
48
- function sections(readme = bundled("README.md")) {
81
+ var IMAGE_LINE = /^\s*(<p\b[^>]*>\s*)?<img\b[^>]*>(\s*<\/p>)?\s*$/i;
82
+ function sections(readme = docsText()) {
49
83
  const out = [];
50
84
  let fence = null;
51
85
  for (const line of readme.split(/\r?\n/)) {
@@ -55,6 +89,7 @@ function sections(readme = bundled("README.md")) {
55
89
  if (fence === null) fence = marker;
56
90
  else if (fence === marker && trimmed.trimEnd().replace(new RegExp(`^\\${marker[0]}+`), "") === "") fence = null;
57
91
  }
92
+ if (fence === null && marker === void 0 && IMAGE_LINE.test(line)) continue;
58
93
  const hashes = line.length - line.replace(/^#+/, "").length;
59
94
  if (fence === null && marker === void 0 && hashes >= 1 && hashes <= 4 && line[hashes] === " ") {
60
95
  out.push({ level: hashes, title: line.slice(hashes).trim(), body: "" });
@@ -227,15 +262,20 @@ function firstMention(block, name) {
227
262
  const at = mentionsAt(text, name)[0];
228
263
  return at === void 0 ? void 0 : byteLength(text.slice(0, at));
229
264
  }
265
+ function leadsWith(block, name) {
266
+ const lead = /^(?:[-*] )?\*\*([^*]+?):?\*\*/.exec(block)?.[1];
267
+ return lead !== void 0 && words(lead).join(" ") === words(name).join(" ");
268
+ }
230
269
  function passages(all, name) {
231
270
  let best;
232
271
  const defining = [];
233
272
  all.forEach((s, i) => {
234
273
  for (const block2 of blocks(s.body)) {
235
274
  const n = mentions(block2, name);
236
- if (n === 0) continue;
275
+ const leads = leadsWith(block2, name);
276
+ if (n === 0 && !leads) continue;
237
277
  const at = firstMention(block2, name);
238
- const defines = at !== void 0 && at < 60;
278
+ const defines = at !== void 0 && at < 60 || leads;
239
279
  if (defines) defining.push([i, block2]);
240
280
  const score = n + (defines ? 1e3 : 0) + mentions(s.title, name) * 100;
241
281
  if (best === void 0 || score > best[1]) best = [i, score, block2];
@@ -461,12 +501,17 @@ function nextStep(grammar, all, known, query) {
461
501
  }
462
502
  function guide(generator) {
463
503
  const configured = OTHER_CONFIGS.find(([, g]) => g === generator)?.[3] ?? null;
464
- const available = bundledNames("trailheads");
504
+ const available = bundledNames("docs/trailheads");
465
505
  const file = configured ?? (available.includes(`from-${generator.toLowerCase()}.md`) ? `from-${generator.toLowerCase()}.md` : void 0);
466
506
  if (file === void 0) return void 0;
467
- return { file, text: available.includes(file) ? bundled(`trailheads/${file}`) : null };
507
+ if (!available.includes(file)) return { file, text: null };
508
+ const { title, body } = docsPage(bundled(`docs/trailheads/${file}`));
509
+ return { file, text: `# ${title}
510
+
511
+ ${body.trim()}
512
+ ` };
468
513
  }
469
- var guideUrl = (file) => `${GUIDES_URL}/v${VERSION}/docs/trailheads/${file}`;
514
+ var guideUrl = (file) => `${SITE_URL}/docs/trailheads/${file.replace(/\.md$/, "")}/`;
470
515
  function from(generator, json) {
471
516
  const known = generators();
472
517
  const found = known.find((g2) => g2.toLowerCase() === generator.toLowerCase() || g2.replace(/\./g, "").toLowerCase() === generator.toLowerCase());
@@ -479,7 +524,7 @@ function from(generator, json) {
479
524
  const g = guide(found);
480
525
  if (json) {
481
526
  const rows2 = (list) => list.map((e) => ({ ...toJson(e), say: e.say }));
482
- const value = { generator: found, words: rows2(theirs), common: rows2(everyone), trailhead: g ? { file: `docs/trailheads/${g.file}`, url: guideUrl(g.file), text: g.text } : null };
527
+ const value = { generator: found, words: rows2(theirs), common: rows2(everyone), trailhead: g ? { file: `site/src/docs/trailheads/${g.file}`, url: guideUrl(g.file), text: g.text } : null };
483
528
  return JSON.stringify(value, null, 2) + "\n";
484
529
  }
485
530
  let out = `${found}'s words, and ssqch's names for them. The ones marked (works) are aliases: they do the same as ssqch's name, and say it once. The others are refused with this hint.
@@ -504,7 +549,7 @@ ${rows(list)}`;
504
549
  Words most generators use
505
550
  ${rows(everyone)}`;
506
551
  if (g && g.text !== null) out += `
507
- The trailhead (docs/trailheads/${g.file}):
552
+ The trailhead (${guideUrl(g.file)}):
508
553
 
509
554
  ${g.text.trimEnd()}
510
555
  `;
@@ -557,6 +602,8 @@ function runDocs(grammar, command) {
557
602
  }
558
603
  export {
559
604
  answer,
605
+ docsPage,
606
+ docsText,
560
607
  names,
561
608
  runDocs,
562
609
  sections,
@@ -8,7 +8,7 @@ import {
8
8
  globProblem,
9
9
  globToRegExp,
10
10
  isGlob
11
- } from "./chunk-TDGBQNGW.js";
11
+ } from "./chunk-NFJJKDRI.js";
12
12
  import {
13
13
  ISSUES_URL,
14
14
  SOMETHING_LARGE
@@ -16,7 +16,7 @@ import {
16
16
  import {
17
17
  describeThrown,
18
18
  settle
19
- } from "./chunk-C35KIPAR.js";
19
+ } from "./chunk-JWCCVTTR.js";
20
20
  import {
21
21
  BuildError,
22
22
  Diagnostics,
@@ -29,7 +29,7 @@ import {
29
29
  readText,
30
30
  warn,
31
31
  warning
32
- } from "./chunk-6XYSFG6V.js";
32
+ } from "./chunk-BGCBSQ4A.js";
33
33
  import {
34
34
  comparePaths
35
35
  } from "./chunk-VJWQSYEG.js";
@@ -179,6 +179,8 @@ var WasmMarkdown = class {
179
179
  return status === DONE ? text : "";
180
180
  }
181
181
  useHooks(hooks, engines) {
182
+ const own = hooks.get("containers/slot");
183
+ if (own) throw new BuildError(`${own.name}: \`slot\` is ssqch's container for a named slot (\`::: slot footer\` inside another container is its \`container.slots.footer\`), so it can't have a template. Rename the container`);
182
184
  this.#hooks = hooks;
183
185
  this.#engines = engines;
184
186
  this.close();
@@ -213,7 +215,7 @@ var WasmMarkdown = class {
213
215
  const [status, text, thrown] = wasm.run(frame, () => wasm.x.md_render(this.#handle, ptr, lens[0], lens[1], flags), file);
214
216
  this.#waited(frame, what);
215
217
  if (status !== DONE) throw failure(text, thrown);
216
- return text;
218
+ return putBackSlots(text);
217
219
  }
218
220
  /** A render that runs nothing of the site's: the calls to its functions it would make, in order. */
219
221
  #dryRun(source, file) {
@@ -325,7 +327,8 @@ var WasmMarkdown = class {
325
327
  highlightCss: o.highlightCss,
326
328
  languages,
327
329
  headingIdsFunction: o.sluggerFn ? number(o.sluggerFn, "markdown.headingIds", true) : null,
328
- hooks: [...this.#hooks.keys()],
330
+ // `slot` is ssqch's container: it always calls back, to be kept for its parent.
331
+ hooks: [...this.#hooks.keys(), "containers/slot"],
329
332
  languagesKey: JSON.stringify(key)
330
333
  });
331
334
  return { json, files: files2 };
@@ -335,6 +338,12 @@ var WasmMarkdown = class {
335
338
  }
336
339
  /** A render hook for the wasm: the template `name` with the page's data and `value` as `key`. */
337
340
  renderHook(name, key, value, data) {
341
+ if (key === "container" && isPlainObject(value)) {
342
+ if (name === "containers/slot") return keepSlot(value);
343
+ const own = { ...value, props: containerProps(value.args) };
344
+ own.slots = takeSlots(own);
345
+ value = own;
346
+ }
338
347
  const template = this.#hooks.get(name);
339
348
  const engines = this.#engines;
340
349
  if (!template || !engines) throw new BuildError(`no template for \`${name}\``);
@@ -386,6 +395,53 @@ var WasmMarkdown = class {
386
395
  return describeThrown(e, this.#root);
387
396
  }
388
397
  };
398
+ function containerProps(args) {
399
+ const props = {};
400
+ for (const [, name, dq, sq, bare] of String(args ?? "").matchAll(/([A-Za-z_][\w-]*)(?:="([^"]*)"|='([^']*)'|=([^\s"']+))?/g)) {
401
+ if (dq !== void 0) props[name] = dq;
402
+ else if (sq !== void 0) {
403
+ if (/^\s*[{[]/.test(sq)) {
404
+ try {
405
+ props[name] = JSON.parse(sq);
406
+ continue;
407
+ } catch {
408
+ }
409
+ }
410
+ props[name] = sq;
411
+ } else if (bare !== void 0) props[name] = bare;
412
+ else props[name] = true;
413
+ }
414
+ return props;
415
+ }
416
+ var slots = /* @__PURE__ */ new Map();
417
+ var slotCount = 0;
418
+ var SLOT = /\uE000slot(\d+)\uE001\n?/g;
419
+ function keepSlot(value) {
420
+ const props = containerProps(value.args);
421
+ const name = typeof props.name === "string" ? props.name : String(value.args ?? "").trim().split(/\s+/)[0] || "default";
422
+ const n = slotCount++;
423
+ slots.set(n, { name, content: String(value.content ?? "") });
424
+ return `\uE000slot${n}\uE001`;
425
+ }
426
+ function takeSlots(value) {
427
+ const found = {};
428
+ if (typeof value.content !== "string" || !value.content.includes("\uE000slot")) return found;
429
+ value.content = value.content.replace(SLOT, (_, n) => {
430
+ const slot = slots.get(Number(n));
431
+ slots.delete(Number(n));
432
+ if (slot) found[slot.name] = String(found[slot.name] ?? "") + slot.content;
433
+ return "";
434
+ });
435
+ return found;
436
+ }
437
+ function putBackSlots(html) {
438
+ if (!html.includes("\uE000slot")) return html;
439
+ return html.replace(SLOT, (_, n) => {
440
+ const slot = slots.get(Number(n));
441
+ slots.delete(Number(n));
442
+ return slot?.content ?? "";
443
+ });
444
+ }
389
445
  var handles = new FinalizationRegistry(({ wasm, handle }) => {
390
446
  if (!wasm.dead) wasm.x.md_drop(handle);
391
447
  });
@@ -2,7 +2,7 @@ import { createRequire as __ssqchCreateRequire } from "node:module";
2
2
  const require = __ssqchCreateRequire(import.meta.url);
3
3
  import {
4
4
  Options
5
- } from "./chunk-JRT7TQQP.js";
5
+ } from "./chunk-HGJ5VWUR.js";
6
6
  import {
7
7
  BUILTINS,
8
8
  addImagePlugin,
@@ -11,10 +11,10 @@ import {
11
11
  imageOptionsFor,
12
12
  meant,
13
13
  parseFormat
14
- } from "./chunk-TN6EEDX2.js";
14
+ } from "./chunk-QMA7CK7B.js";
15
15
  import {
16
16
  bail
17
- } from "./chunk-6XYSFG6V.js";
17
+ } from "./chunk-BGCBSQ4A.js";
18
18
 
19
19
  // src/modules/image.ts
20
20
  import fs from "node:fs";