ssqch 0.9.0 → 0.10.1

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 (94) hide show
  1. package/README.md +1 -1
  2. package/bundled/completions/bash +1 -1
  3. package/bundled/completions/elvish +1 -0
  4. package/bundled/completions/fish +1 -0
  5. package/bundled/completions/powershell +1 -0
  6. package/bundled/completions/zsh +1 -0
  7. package/bundled/docs/agents.md +70 -0
  8. package/bundled/docs/benchmarks.md +29 -0
  9. package/bundled/docs/build-summary.md +57 -0
  10. package/bundled/docs/comparing-builds.md +51 -0
  11. package/bundled/docs/configuring.md +138 -0
  12. package/bundled/docs/content-schemas.md +54 -0
  13. package/bundled/docs/css-and-javascript.md +33 -0
  14. package/bundled/docs/data-files.md +55 -0
  15. package/bundled/docs/deploying.md +47 -0
  16. package/bundled/docs/field-guide.md +144 -0
  17. package/bundled/docs/footprint.md +27 -0
  18. package/bundled/docs/github-pages.md +41 -0
  19. package/bundled/docs/index.md +26 -0
  20. package/bundled/docs/install.md +27 -0
  21. package/bundled/docs/known-gaps.md +18 -0
  22. package/bundled/docs/markdown.md +114 -0
  23. package/bundled/docs/multilingual.md +14 -0
  24. package/bundled/docs/nav.yml +50 -0
  25. package/bundled/docs/netlify.md +30 -0
  26. package/bundled/docs/new-pages.md +42 -0
  27. package/bundled/docs/plugins.md +13 -0
  28. package/bundled/docs/rust-plugins.md +32 -0
  29. package/bundled/docs/seo.md +19 -0
  30. package/bundled/docs/template-languages.md +106 -0
  31. package/bundled/docs/templates.md +37 -0
  32. package/bundled/docs/themes.md +31 -0
  33. package/bundled/{trailheads → docs/trailheads}/from-component-frameworks.md +7 -3
  34. package/bundled/{trailheads → docs/trailheads}/from-docusaurus.md +7 -4
  35. package/bundled/{trailheads → docs/trailheads}/from-eleventy.md +7 -4
  36. package/bundled/{trailheads → docs/trailheads}/from-hexo.md +7 -4
  37. package/bundled/{trailheads → docs/trailheads}/from-jekyll.md +6 -3
  38. package/bundled/{trailheads → docs/trailheads}/from-mkdocs.md +8 -5
  39. package/bundled/{trailheads → docs/trailheads}/from-zola.md +6 -3
  40. package/bundled/docs/trailheads.md +38 -0
  41. package/bundled/docs/where-values-come-from.md +57 -0
  42. package/bundled/ssqch.d.ts +10 -3
  43. package/lib/assets.js +18 -12
  44. package/lib/{chunk-7PWCYHTJ.js → chunk-26SHWRC6.js} +6 -8
  45. package/lib/{chunk-GUKSZ2XM.js → chunk-3BQJY6GF.js} +4 -6
  46. package/lib/{chunk-TICWN55Z.js → chunk-3LODFCCH.js} +2 -3
  47. package/lib/{chunk-TVU3OPPK.js → chunk-3NDFUMV2.js} +3 -3
  48. package/lib/{chunk-YTHQBMDJ.js → chunk-6OUT5VFK.js} +3 -6
  49. package/lib/{chunk-HXCLCXRT.js → chunk-6RSZV5O2.js} +5 -3
  50. package/lib/{chunk-4Q6WMTER.js → chunk-7JGYYAKI.js} +1 -1
  51. package/lib/{chunk-MI6EJWA2.js → chunk-BT3NVQOD.js} +1 -1
  52. package/lib/{chunk-DDV6JEC2.js → chunk-BXARVN5Z.js} +1 -1
  53. package/lib/{chunk-RNJFPFXE.js → chunk-CXRHH5P5.js} +5 -6
  54. package/lib/{chunk-HPXAZ2HU.js → chunk-DNWA7WNO.js} +1 -1
  55. package/lib/{chunk-SURPOAW7.js → chunk-DTSTCVRX.js} +8 -9
  56. package/lib/{chunk-7SD7K567.js → chunk-DUGGZ4EE.js} +1 -1
  57. package/lib/{chunk-7XLK2GEG.js → chunk-ERNVEZOK.js} +1 -1
  58. package/lib/{chunk-3A647I3N.js → chunk-FYRC2HBU.js} +4 -6
  59. package/lib/{chunk-IJWHOFRP.js → chunk-FYU22VDK.js} +12 -13
  60. package/lib/{chunk-II5DEH3Q.js → chunk-FZGJUJAL.js} +5 -7
  61. package/lib/{chunk-BEGC7YP6.js → chunk-G67W2FTJ.js} +9 -11
  62. package/lib/{chunk-7RDRZHJD.js → chunk-HMVYNV6M.js} +13 -15
  63. package/lib/{chunk-DELWRJAO.js → chunk-HNG372DW.js} +143 -74
  64. package/lib/{chunk-47P4YREZ.js → chunk-II7ZRIAC.js} +11 -13
  65. package/lib/{chunk-NCWFYT74.js → chunk-IOXCGMSF.js} +5 -7
  66. package/lib/{chunk-GRWMGC7D.js → chunk-JFPLNHEQ.js} +2410 -2298
  67. package/lib/{chunk-LPHNACE4.js → chunk-LU73FTIR.js} +10 -11
  68. package/lib/{chunk-D2XE2GTY.js → chunk-LYPKL524.js} +9 -10
  69. package/lib/{chunk-NKXEPHRZ.js → chunk-MDB3D3LP.js} +106 -4
  70. package/lib/{chunk-CZ4XQC56.js → chunk-MDG5A4NI.js} +15 -13
  71. package/lib/{chunk-SXMJ52IK.js → chunk-MUYWL4ZX.js} +58 -19
  72. package/lib/{chunk-R7K3D5W5.js → chunk-P2TRR6XK.js} +83 -24
  73. package/lib/{chunk-SF4I6Z7S.js → chunk-R2YGC3VE.js} +2 -3
  74. package/lib/{chunk-76NTVE34.js → chunk-RFNLZM7W.js} +2 -4
  75. package/lib/{chunk-3K3ANWZ2.js → chunk-X7C6GFUM.js} +4 -4
  76. package/lib/{chunk-XMXBHXZR.js → chunk-XR7GFL4B.js} +12 -13
  77. package/lib/{chunk-NNUKIGOO.js → chunk-ZZBHBLDB.js} +16 -18
  78. package/lib/cli.js +25 -25
  79. package/lib/elements.js +10 -12
  80. package/lib/image.js +10 -11
  81. package/lib/links.js +13 -15
  82. package/lib/minify.js +9 -10
  83. package/lib/redirects.js +11 -13
  84. package/lib/rss.js +22 -22
  85. package/lib/sass.js +10 -12
  86. package/lib/sitemap.js +10 -12
  87. package/lib/ssqch.js +4 -5
  88. package/package.json +2 -2
  89. package/types/index.d.ts +9 -2
  90. package/types/rss.d.ts +1 -1
  91. package/bundled/README.md +0 -1314
  92. package/lib/chunk-VJWQSYEG.js +0 -119
  93. package/lib/{chunk-DELWRJAO.js.LEGAL.txt → chunk-HNG372DW.js.LEGAL.txt} +0 -0
  94. package/lib/{chunk-GRWMGC7D.js.LEGAL.txt → chunk-JFPLNHEQ.js.LEGAL.txt} +3 -3
@@ -2,20 +2,23 @@ import { createRequire as __ssqchCreateRequire } from "node:module";
2
2
  const require = __ssqchCreateRequire(import.meta.url);
3
3
  import {
4
4
  commandLine
5
- } from "./chunk-4Q6WMTER.js";
5
+ } from "./chunk-7JGYYAKI.js";
6
6
  import {
7
7
  builtinFilters,
8
8
  excerpt,
9
9
  headings
10
- } from "./chunk-3A647I3N.js";
10
+ } from "./chunk-FYRC2HBU.js";
11
11
  import {
12
12
  measure,
13
13
  overBudget
14
- } from "./chunk-II5DEH3Q.js";
14
+ } from "./chunk-FZGJUJAL.js";
15
15
  import {
16
16
  checkPages,
17
17
  rewriteBase
18
- } from "./chunk-R7K3D5W5.js";
18
+ } from "./chunk-P2TRR6XK.js";
19
+ import {
20
+ Profile
21
+ } from "./chunk-MDB3D3LP.js";
19
22
  import {
20
23
  VERSION
21
24
  } from "./chunk-AD3HAW3W.js";
@@ -23,7 +26,7 @@ import {
23
26
  dirsOf,
24
27
  shownDir,
25
28
  shownOutput
26
- } from "./chunk-DDV6JEC2.js";
29
+ } from "./chunk-BXARVN5Z.js";
27
30
  import {
28
31
  beginFenceCache,
29
32
  loadHookTemplates,
@@ -32,7 +35,7 @@ import {
32
35
  saveFenceCache,
33
36
  site,
34
37
  writeHighlightCss
35
- } from "./chunk-NCWFYT74.js";
38
+ } from "./chunk-IOXCGMSF.js";
36
39
  import {
37
40
  closest,
38
41
  closestPath
@@ -42,7 +45,7 @@ import {
42
45
  globSet,
43
46
  globToRegExp,
44
47
  isGlob
45
- } from "./chunk-HPXAZ2HU.js";
48
+ } from "./chunk-DNWA7WNO.js";
46
49
  import {
47
50
  ISSUES_URL,
48
51
  PASSED_THIS_TREE,
@@ -54,7 +57,7 @@ import {
54
57
  settle,
55
58
  shownPath,
56
59
  watchSettle
57
- } from "./chunk-76NTVE34.js";
60
+ } from "./chunk-RFNLZM7W.js";
58
61
  import {
59
62
  BuildError,
60
63
  Diagnostics,
@@ -64,12 +67,18 @@ import {
64
67
  aliasUsed,
65
68
  bail,
66
69
  buildTime,
70
+ comparePaths,
71
+ compareText,
67
72
  context,
68
73
  decodeText,
74
+ displayPath,
69
75
  error,
70
76
  find,
71
77
  getPath,
72
78
  isCapturing,
79
+ isDir,
80
+ isFile,
81
+ isInside,
73
82
  isPlainObject,
74
83
  loadDataFile,
75
84
  merge,
@@ -77,28 +86,20 @@ import {
77
86
  normalizeTags,
78
87
  parseFrontMatter,
79
88
  progress,
89
+ readFollowing,
80
90
  readText,
91
+ realPath,
92
+ relative,
81
93
  sameValue,
82
94
  setOwn,
95
+ shown,
96
+ slashes,
83
97
  sourceDateEpoch,
84
98
  toDate,
99
+ walkFiles,
85
100
  warn,
86
101
  warning
87
- } from "./chunk-GRWMGC7D.js";
88
- import {
89
- comparePaths,
90
- compareText,
91
- displayPath,
92
- isDir,
93
- isFile,
94
- isInside,
95
- readFollowing,
96
- realPath,
97
- relative,
98
- shown,
99
- slashes,
100
- walkFiles
101
- } from "./chunk-VJWQSYEG.js";
102
+ } from "./chunk-JFPLNHEQ.js";
102
103
  import {
103
104
  __commonJS,
104
105
  __export,
@@ -35741,10 +35742,18 @@ var Site = class {
35741
35742
  keepLayers;
35742
35743
  /** Set by the build: a page's rendered body, on demand (for `templateContent`). */
35743
35744
  contentOf = () => void 0;
35745
+ /** What `ssqch build --profile` reports, and the `slow-call` warnings (src/profile.ts). */
35746
+ profile;
35744
35747
  constructor(config, keepLayers = false) {
35745
35748
  this.config = config;
35746
35749
  this.dirs = dirsOf(config);
35747
35750
  this.keepLayers = keepLayers;
35751
+ this.profile = new Profile(config.profile);
35752
+ }
35753
+ /** A data file's value, timed with `--profile`. One that fetches can take a while on purpose, so it's no `slow-call`. */
35754
+ loadData(file) {
35755
+ const load = () => loadDataFile(file, this.config.dataExtensions);
35756
+ return this.profile.detailed ? this.profile.time("data", shown(this.dirs.root, file), false, load) : load();
35748
35757
  }
35749
35758
  seenLower;
35750
35759
  caseBlind;
@@ -35797,6 +35806,10 @@ var Site = class {
35797
35806
  });
35798
35807
  }
35799
35808
  for (const [name, fn] of config.filters) globals.set(name, fn);
35809
+ for (const [name, fn] of globals) {
35810
+ const own = config.siteFilters.has(name);
35811
+ if (this.profile.times(own)) globals.set(name, this.profile.wrap("filters", name, fn, own, config.definedIn.get(`filters.${name}`)));
35812
+ }
35800
35813
  this.themeIncludes = config.themes.map((theme) => path6.join(theme, "_includes"));
35801
35814
  const env = { config, dirs, includeDirs: [dirs.includes, ...this.themeIncludes], globals, pipeFilters, strict: config.strict };
35802
35815
  const byName = this.engines.byName;
@@ -35815,7 +35828,7 @@ var Site = class {
35815
35828
  byName.set(name, {
35816
35829
  render: (source, data2, ctx) => {
35817
35830
  try {
35818
- const out = fn(source, data2, ctx.name);
35831
+ const out = fn(source, data2, ctx.name, { kind: ctx.kind ?? "body", path: this.display(ctx.inputPath) });
35819
35832
  return typeof out === "string" ? out : out.catch((e) => {
35820
35833
  throw new BuildError(describeThrown(e, dirs.root));
35821
35834
  });
@@ -35825,6 +35838,13 @@ var Site = class {
35825
35838
  }
35826
35839
  });
35827
35840
  }
35841
+ if (this.profile.detailed) {
35842
+ for (const [name, engine] of byName) {
35843
+ const timed = Object.create(engine);
35844
+ timed.render = (source, data2, ctx) => this.profile.time("engines", name, false, () => engine.render(source, data2, ctx));
35845
+ byName.set(name, timed);
35846
+ }
35847
+ }
35828
35848
  for (const format2 of config.templateFormats) {
35829
35849
  try {
35830
35850
  this.engines.get(format2);
@@ -35846,7 +35866,7 @@ var Site = class {
35846
35866
  const provided = await Promise.all(config.globalData.map(async ({ name, value, fn }) => {
35847
35867
  if (!fn) return [name, value];
35848
35868
  try {
35849
- return [name, await settle(fn())];
35869
+ return [name, await settle(this.profile.detailed ? this.profile.time("data", `data.${name}`, false, fn) : fn())];
35850
35870
  } catch (e) {
35851
35871
  throw new BuildError(`global data \`${name}\` failed: data.${name}: ${describeThrown(e, dirs.root)}`);
35852
35872
  }
@@ -35870,7 +35890,7 @@ var Site = class {
35870
35890
  const [themePages, themeCopies] = this.themeFiles();
35871
35891
  this.files.push(...themePages);
35872
35892
  this.themeCopies = themeCopies;
35873
- const commitDates = config.lastModified === "git" ? this.gitDates() : /* @__PURE__ */ new Map();
35893
+ const commitDates = config.lastModified === "git" || config.dateFallback === "git" ? this.gitDates(config.lastModified === "git" ? "lastModified" : "dateFallback") : /* @__PURE__ */ new Map();
35874
35894
  const dirData = await this.loadDirectoryData();
35875
35895
  const sources = await readAll(this.files);
35876
35896
  const tpls = await collectErrors(this.files.map((file, i2) => () => this.loadTemplate(file, sources[i2], dirData, commitDates)));
@@ -35882,8 +35902,9 @@ var Site = class {
35882
35902
  this.drafts = tpls.length - this.tpls.length;
35883
35903
  timer.lap("read");
35884
35904
  const overCollections = (t) => typeof t.data.pagination?.data === "string" && t.data.pagination.data.startsWith("collections");
35885
- const immediate = this.tpls.filter((t) => !overCollections(t));
35886
- const deferred = this.tpls.filter(overCollections);
35905
+ const waits = (t) => overCollections(t) || readsCollections(t.data.computed);
35906
+ const immediate = this.tpls.filter((t) => !waits(t));
35907
+ const deferred = this.tpls.filter(waits);
35887
35908
  const add2 = (pages) => {
35888
35909
  for (const page of pages.flat()) {
35889
35910
  page.index = this.pages.length;
@@ -35911,7 +35932,7 @@ var Site = class {
35911
35932
  const stem = name.slice(0, name.length - path6.extname(name).length);
35912
35933
  if (isDir(file)) setOwn(data2, name, await this.loadGlobalData(file, skipped, `${prefix}${name}/`));
35913
35934
  else {
35914
- const value = await loadDataFile(file, this.config.dataExtensions);
35935
+ const value = await this.loadData(file);
35915
35936
  if (value === NOT_DATA) skipped.push(`${prefix}${name}`);
35916
35937
  else setOwn(data2, stem, value);
35917
35938
  }
@@ -36043,12 +36064,12 @@ var Site = class {
36043
36064
  * with uncommitted changes are left out (they use their modification time). Not a
36044
36065
  * repository, or no git: nothing, with a warning.
36045
36066
  */
36046
- gitDates() {
36067
+ gitDates(setting) {
36047
36068
  const { config, dirs } = this;
36048
36069
  const git = (...args) => spawnSync("git", ["-C", dirs.root, "-c", "core.quotepath=off", ...args], { encoding: "utf8", maxBuffer: 1 << 30 });
36049
36070
  const dates = /* @__PURE__ */ new Map();
36050
36071
  const lost = (message) => {
36051
- if (!config.quiet) warn(warning("last-modified", `lastModified: ${message}`));
36072
+ if (!config.quiet) warn(warning("last-modified", `${setting}: ${message}`));
36052
36073
  };
36053
36074
  const top = git("rev-parse", "--show-toplevel");
36054
36075
  if (top.error) {
@@ -36106,7 +36127,7 @@ var Site = class {
36106
36127
  for (const candidate of candidates) {
36107
36128
  const file = path6.join(dir, candidate);
36108
36129
  if (!(this.seen.has(file) || isFile(file))) continue;
36109
- const value = await loadDataFile(file, this.config.dataExtensions);
36130
+ const value = await this.loadData(file);
36110
36131
  if (!isPlainObject(value)) continue;
36111
36132
  const layer = { ...value };
36112
36133
  try {
@@ -36183,7 +36204,7 @@ var Site = class {
36183
36204
  for (const suffix of ["json", "data.json", ...[...config.dataExtensions.keys()].map((ext2) => `data.${ext2}`)]) {
36184
36205
  const candidate = path6.join(path6.dirname(file), `${stem}.${suffix}`);
36185
36206
  if (!this.sawFile(candidate)) continue;
36186
- const value = await loadDataFile(candidate, config.dataExtensions);
36207
+ const value = await this.loadData(candidate);
36187
36208
  if (!isPlainObject(value)) continue;
36188
36209
  const layer = { ...value };
36189
36210
  try {
@@ -36198,22 +36219,9 @@ var Site = class {
36198
36219
  own = merge(own, front, config.deepMerge);
36199
36220
  if (this.keepLayers && frontKeys.length) layers.push(["front matter", front]);
36200
36221
  const computedLayout = own.computed?.layout;
36201
- if (computedLayout !== void 0 && computedLayout !== null) {
36202
- if (typeof computedLayout === "string" && !computedLayout.includes("{{") && !computedLayout.includes("{%") && !computedLayout.includes("<%")) own.layout = computedLayout;
36203
- else bail("`layout` in computed isn't applied, because the layout is chosen before computed runs. Set `layout` in the front matter or a data file");
36204
- }
36222
+ if (typeof computedLayout === "string" && !dependsOnPage(computedLayout)) own.layout = computedLayout;
36205
36223
  if (isPlainObject(own.computed) && Object.hasOwn(own.computed, "page")) bail("`page` in computed isn't applied, because `page` is ssqch's: its url, inputPath, date and headings. Give the value another name (`computed: { meta: ... }`); front matter is at the top level already (`title`, not `page.title`)");
36206
- const chain = [];
36207
- const names = [];
36208
- let next = typeof own.layout === "string" && own.layout !== "" ? own.layout : void 0;
36209
- while (typeof next === "string") {
36210
- const start = names.indexOf(next);
36211
- if (start !== -1) bail(`${PASSED_THIS_TREE}. Layout loop: ${names.slice(start).join(" -> ")} -> ${next}`);
36212
- const layout = this.loadLayout(next);
36213
- names.push(next);
36214
- chain.push(layout);
36215
- next = layout.data.layout;
36216
- }
36224
+ const chain = this.layoutChain(own.layout);
36217
36225
  let data2 = this.global;
36218
36226
  let layoutLayers = 0;
36219
36227
  for (const layout of [...chain].reverse()) {
@@ -36245,12 +36253,28 @@ var Site = class {
36245
36253
  filePathStem: parent === "" ? `/${stem}` : `/${parent}/${stem}`,
36246
36254
  mtime,
36247
36255
  fileDate,
36248
- lastModified: config.lastModified === "git" ? commitDates.get(file) ?? mtime : config.lastModified === "file" ? mtime : void 0
36256
+ lastModified: config.lastModified === "git" ? commitDates.get(file) ?? mtime : config.lastModified === "file" ? mtime : void 0,
36257
+ commitDate: config.dateFallback === "git" ? commitDates.get(file) : void 0
36249
36258
  };
36250
36259
  } catch (e) {
36251
36260
  throw context(e, `in ${rel}`);
36252
36261
  }
36253
36262
  }
36263
+ /** The layouts `layout` names, innermost first: that layout, the one its front matter names, and so on. `""`, `false` and `null` are none. */
36264
+ layoutChain(layout) {
36265
+ const chain = [];
36266
+ const names = [];
36267
+ let next = typeof layout === "string" && layout !== "" ? layout : void 0;
36268
+ while (typeof next === "string") {
36269
+ const start = names.indexOf(next);
36270
+ if (start !== -1) bail(`${PASSED_THIS_TREE}. Layout loop: ${names.slice(start).join(" -> ")} -> ${next}`);
36271
+ const found2 = this.loadLayout(next);
36272
+ names.push(next);
36273
+ chain.push(found2);
36274
+ next = found2.data.layout;
36275
+ }
36276
+ return chain;
36277
+ }
36254
36278
  // ---- pagination, computed data and permalinks ----------------------------------------------
36255
36279
  async expand(tpl, collections) {
36256
36280
  try {
@@ -36266,6 +36290,7 @@ var Site = class {
36266
36290
  let fromFileTime = false;
36267
36291
  if (tpl.data.date !== void 0 && tpl.data.date !== null) date = toDate(tpl.data.date) ?? bail(`can't parse date ${show(tpl.data.date)}`);
36268
36292
  else if (tpl.fileDate) date = tpl.fileDate;
36293
+ else if (tpl.commitDate) [date, fromFileTime] = [tpl.commitDate, true];
36269
36294
  else if (sourceDateEpoch() !== void 0) date = new Date(sourceDateEpoch());
36270
36295
  else [date, fromFileTime] = [tpl.mtime, true];
36271
36296
  const basePage = (url, outputPath, when) => {
@@ -36310,6 +36335,15 @@ var Site = class {
36310
36335
  }
36311
36336
  }
36312
36337
  }
36338
+ let layouts;
36339
+ if (isPlainObject(computed) && Object.hasOwn(computed, "layout") && !(typeof computed.layout === "string" && !dependsOnPage(computed.layout))) {
36340
+ const value = data2.layout;
36341
+ if (value !== void 0 && value !== null && value !== false && typeof value !== "string") bail(`computed.layout must be a layout's name, \`""\` or \`false\`, not ${show(value)}`);
36342
+ layouts = this.layoutChain(value);
36343
+ for (const layout of layouts) {
36344
+ for (const [key, v] of Object.entries(layout.data)) if (key !== "layout" && data2[key] === void 0) data2[key] = v;
36345
+ }
36346
+ }
36313
36347
  let pageDate = date;
36314
36348
  let fromFile = fromFileTime;
36315
36349
  if (isPlainObject(computed) && computed.date !== void 0 && computed.date !== null && data2.date !== void 0 && data2.date !== null) {
@@ -36321,7 +36355,8 @@ var Site = class {
36321
36355
  if (permalink === false) url = null;
36322
36356
  else if (typeof permalink === "string") {
36323
36357
  const dynamic = data2.dynamicPermalink !== false;
36324
- url = (dynamic && hasTags(tpl, permalink) ? await this.renderDataString(tpl, "permalink", permalink, data2) : permalink).trim();
36358
+ url = (dynamic && hasTags(tpl, this.config, permalink) ? await this.renderDataString(tpl, "permalink", permalink, data2) : permalink).trim();
36359
+ if (dynamic && (/\{\{|\{%|<%/.test(url) || /^<p>/i.test(url))) bail(`permalink ${show(url)} isn't a URL: it was rendered with \`${dataStringEngine(tpl, this.config)}\`, which left it like that. Write it in that template language, or set \`dynamicPermalink: false\` to use it as written`);
36325
36360
  } else if (permalink !== void 0 && permalink !== null) bail("permalink must be a string or false");
36326
36361
  else if (tpl.engines.length && tpl.engines.every((e) => e === "txt")) url = `/${tpl.rel}`;
36327
36362
  else {
@@ -36342,7 +36377,7 @@ var Site = class {
36342
36377
  delete data2.collections;
36343
36378
  const excluded = Boolean(data2.excludeFromCollections);
36344
36379
  const inCollections = !excluded && !tpl.plainCopy && (index2 === 0 || Boolean(pagination?.addAllPagesToCollections));
36345
- pages.push({ index: -1, tpl, data: data2, url, output, date: pageDate, when: fromFile ? UNDATED : BigInt(pageDate.getTime()) * 1000000n, inCollections });
36380
+ pages.push({ index: -1, tpl, data: data2, url, output, date: pageDate, when: fromFile ? UNDATED : BigInt(pageDate.getTime()) * 1000000n, inCollections, ...layouts ? { layouts } : {} });
36346
36381
  }
36347
36382
  if (pagination && pages.length) {
36348
36383
  const hrefs = pages.map((p) => p.url ?? void 0);
@@ -36380,11 +36415,11 @@ var Site = class {
36380
36415
  }
36381
36416
  /** Renders a `permalink` or `computed` string with the page's own template language. */
36382
36417
  async renderDataString(tpl, what, text4, data2) {
36383
- const ctx = { name: `${tpl.rel} (${what})`, inputPath: tpl.input };
36384
- return this.engines.get(dataStringEngine(tpl)).render(text4, data2, ctx);
36418
+ const ctx = { name: `${tpl.rel} (${what})`, inputPath: tpl.input, kind: what };
36419
+ return this.engines.get(dataStringEngine(tpl, this.config)).render(text4, data2, ctx);
36385
36420
  }
36386
36421
  async renderComputed(value, data2, tpl) {
36387
- if (typeof value === "string") return hasTags(tpl, value) ? this.renderDataString(tpl, "computed", value, data2) : value;
36422
+ if (typeof value === "string") return hasTags(tpl, this.config, value) ? this.renderDataString(tpl, "computed", value, data2) : value;
36388
36423
  if (isPlainObject(value)) {
36389
36424
  const out = {};
36390
36425
  for (const [k, v] of Object.entries(value)) out[k] = await this.renderComputed(v, data2, tpl);
@@ -36477,8 +36512,9 @@ var Site = class {
36477
36512
  for (const [tag, items] of byTag) collections[tag] = items;
36478
36513
  const pages = collectionApi(all);
36479
36514
  for (const [name, fn] of this.config.collections) {
36515
+ const from = this.config.definedIn.get(`collections.${name}`);
36480
36516
  try {
36481
- collections[name] = await settle(fn(pages));
36517
+ collections[name] = await settle(this.profile.time("collections", name, true, () => fn(pages), from));
36482
36518
  } catch (e) {
36483
36519
  throw new BuildError(`collection \`${name}\` failed: ${describeThrown(e, this.dirs.root)}`);
36484
36520
  }
@@ -36550,11 +36586,22 @@ function renderEngines(v) {
36550
36586
  if (!names.length) bail("`render` is empty: name an engine (`md`), or use `render: false` to skip processing");
36551
36587
  return names;
36552
36588
  }
36553
- function dataStringEngine(tpl) {
36554
- return tpl.engines.find((e) => e !== "md" && e !== "html" && e !== "txt") ?? "edge";
36589
+ var dependsOnPage = (value) => value.includes("{{") || value.includes("{%") || value.includes("<%");
36590
+ function readsCollections(computed) {
36591
+ if (typeof computed === "string") return computed.includes("collections");
36592
+ if (typeof computed === "function") return Function.prototype.toString.call(computed).includes("collections");
36593
+ if (Array.isArray(computed)) return computed.some(readsCollections);
36594
+ if (isPlainObject(computed)) return Object.values(computed).some(readsCollections);
36595
+ return false;
36596
+ }
36597
+ var TEMPLATE_LANGUAGES = /* @__PURE__ */ new Set(["edge", "njk", "jinja", "j2", "liquid", "hbs", "handlebars", "mustache", "ejs"]);
36598
+ function dataStringEngine(tpl, config) {
36599
+ const own = (e) => TEMPLATE_LANGUAGES.has(e) && !config.engines.has(e);
36600
+ const markdown = config.markdownEngine;
36601
+ return tpl.engines.find(own) ?? (markdown !== null && own(markdown) ? markdown : "edge");
36555
36602
  }
36556
- function hasTags(tpl, s) {
36557
- return dataStringEngine(tpl) === "ejs" ? s.includes("<%") : s.includes("{{") || s.includes("{%");
36603
+ function hasTags(tpl, config, s) {
36604
+ return dataStringEngine(tpl, config) === "ejs" ? s.includes("<%") : s.includes("{{") || s.includes("{%");
36558
36605
  }
36559
36606
  async function readAll(files) {
36560
36607
  const out = new Array(files.length);
@@ -36598,7 +36645,7 @@ async function build(config) {
36598
36645
  beginFenceCache(dirs.root);
36599
36646
  if (!isDir(dirs.input)) bail(`input directory ${shownDir(config, config.input)} does not exist`);
36600
36647
  const built = await runFileBuilders(config, dirs);
36601
- await runHooks(config, dirs, "beforeBuild", config.beforeBuild, void 0);
36648
+ await runHooks(config, dirs, "beforeBuild", config.beforeBuild, void 0, site2.profile);
36602
36649
  await site2.prepare(timer);
36603
36650
  await checkPages(site2);
36604
36651
  checkForeignKeys(site2);
@@ -36654,7 +36701,7 @@ async function build(config) {
36654
36701
  timings: [],
36655
36702
  summary: []
36656
36703
  };
36657
- await runHooks(config, dirs, "afterBuild", config.afterBuild, report);
36704
+ await runHooks(config, dirs, "afterBuild", config.afterBuild, report, site2.profile);
36658
36705
  if (config.budgets.length) for (const found2 of overBudget(await measure(dirs.output), config.budgets)) warn(found2);
36659
36706
  for (const [label, line] of config.summaries) {
36660
36707
  const value = line(config);
@@ -36664,6 +36711,8 @@ async function build(config) {
36664
36711
  timer.lap("after");
36665
36712
  report.durationMs = performance.now() - started;
36666
36713
  report.timings = timer.timings;
36714
+ for (const slow of site2.profile.slowCalls()) warn(slow);
36715
+ if (config.profile) report.profile = site2.profile.report();
36667
36716
  return report;
36668
36717
  }
36669
36718
  async function inspectPages(config) {
@@ -36678,7 +36727,7 @@ async function inspectPages(config) {
36678
36727
  input: p.tpl.input,
36679
36728
  output: p.output,
36680
36729
  engines: p.tpl.engines,
36681
- layouts: p.tpl.layouts.map((l) => l.name),
36730
+ layouts: (p.layouts ?? p.tpl.layouts).map((l) => l.name),
36682
36731
  date: p.date,
36683
36732
  dateFromName: p.tpl.fileDate !== void 0,
36684
36733
  inCollections: p.inCollections,
@@ -36784,6 +36833,7 @@ var Renderer = class {
36784
36833
  for (const page of pages) {
36785
36834
  this.borrowedFailure = false;
36786
36835
  rendering(this.site.display(page.tpl.input));
36836
+ this.site.profile.at = shown(this.site.dirs.root, page.tpl.input);
36787
36837
  try {
36788
36838
  await this.render(page);
36789
36839
  } catch (e) {
@@ -36794,6 +36844,7 @@ var Renderer = class {
36794
36844
  }
36795
36845
  }
36796
36846
  rendering(void 0);
36847
+ this.site.profile.at = void 0;
36797
36848
  await Promise.all(this.pending);
36798
36849
  if (this.writeError !== void 0) this.errors.push({ error: this.writeError, phase: 2 });
36799
36850
  if (this.errors.length) {
@@ -36824,17 +36875,19 @@ var Renderer = class {
36824
36875
  }
36825
36876
  this.renderMs += performance.now() - start;
36826
36877
  if (page.output === null) return;
36827
- if (tpl.layouts.length) {
36878
+ const layouts = page.layouts ?? tpl.layouts;
36879
+ if (layouts.length) {
36828
36880
  const data2 = this.data(page);
36829
36881
  const had = this.bodies.get(page.index);
36830
36882
  this.bodies.set(page.index, content);
36831
36883
  try {
36832
36884
  data2.page = site2.pageWithBody(page);
36833
- for (const layout of tpl.layouts) {
36885
+ for (const layout of layouts) {
36886
+ const layoutStart = performance.now();
36834
36887
  data2.content = content;
36835
36888
  let text4 = layout.body;
36836
36889
  for (const name of layout.engines) {
36837
- const ctx = { name: layout.name, inputPath: layout.path, cacheKey: `${layout.name}#${name}` };
36890
+ const ctx = { name: layout.name, inputPath: layout.path, cacheKey: `${layout.name}#${name}`, kind: "layout" };
36838
36891
  const engine = site2.engines.get(name);
36839
36892
  try {
36840
36893
  const out = engine.render(text4, data2, ctx);
@@ -36844,6 +36897,7 @@ var Renderer = class {
36844
36897
  }
36845
36898
  }
36846
36899
  content = text4;
36900
+ if (site2.profile.detailed) site2.profile.add("layouts", layout.name, performance.now() - layoutStart, false);
36847
36901
  }
36848
36902
  } finally {
36849
36903
  if (had === void 0 && !this.keep) this.bodies.delete(page.index);
@@ -36851,9 +36905,13 @@ var Renderer = class {
36851
36905
  }
36852
36906
  const output = page.output;
36853
36907
  const info = { url: page.url ?? "", inputPath: site2.display(tpl.input), outputPath: output };
36854
- for (const [name, transform] of [...config.htmlTransforms, ...config.transforms]) {
36908
+ const transforms = [...config.htmlTransforms, ...config.transforms];
36909
+ for (let i2 = 0; i2 < transforms.length; i2++) {
36910
+ const [name, transform] = transforms[i2];
36911
+ const own = i2 >= config.htmlTransforms.length;
36912
+ const run = () => transform(content, info);
36855
36913
  try {
36856
- content = await transform(content, info);
36914
+ content = await (site2.profile.times(own) ? site2.profile.time("transforms", name, own, run, config.definedIn.get(`transforms.${name}`)) : run());
36857
36915
  } catch (e) {
36858
36916
  throw new BuildError(`transform \`${name}\` failed for ${tpl.rel}: ${describeThrown(e, dirs.root)}`);
36859
36917
  }
@@ -36865,6 +36923,11 @@ var Renderer = class {
36865
36923
  throw context(e, `in ${tpl.rel}`);
36866
36924
  }
36867
36925
  }
36926
+ if (site2.profile.detailed) {
36927
+ const ms = performance.now() - start;
36928
+ site2.profile.add("pages", page.url ?? shown(dirs.root, output), ms, false);
36929
+ site2.profile.add("templates", shown(dirs.root, tpl.input), ms, false);
36930
+ }
36868
36931
  const changed = !(config.serving && sameContents(output, content));
36869
36932
  this.written.set(page.index, { file: output, bytes: Buffer.byteLength(content), changed });
36870
36933
  if (changed) await this.write(output, content);
@@ -37040,7 +37103,7 @@ function checkForeignGlobals(site2) {
37040
37103
  const sources = [];
37041
37104
  const seen = /* @__PURE__ */ new Set();
37042
37105
  for (const tpl of site2.tpls) {
37043
- sources.push([site2.display(tpl.input), tpl.body, tpl]);
37106
+ if (tpl.engines.some((e) => e !== "md" && e !== "html" && e !== "txt")) sources.push([site2.display(tpl.input), tpl.body, tpl]);
37044
37107
  for (const layout of tpl.layouts) {
37045
37108
  if (seen.has(layout.path)) continue;
37046
37109
  seen.add(layout.path);
@@ -37099,14 +37162,18 @@ function hookEvent(config, dirs, report) {
37099
37162
  if (report) event.written = [...report.written];
37100
37163
  return event;
37101
37164
  }
37102
- async function runHooks(config, dirs, event, hooks, report) {
37165
+ async function runHooks(config, dirs, event, hooks, report, profile) {
37103
37166
  const failed = event === "beforeBuild" ? "before_build hook failed" : "after_build hook failed";
37104
37167
  for (const hook of hooks) {
37105
37168
  try {
37106
- if ("run" in hook) runCommand(config, dirs, event, hook.run);
37107
- else {
37169
+ if ("run" in hook) {
37170
+ const run = () => runCommand(config, dirs, event, hook.run);
37171
+ if (profile?.detailed) profile.time("hooks", `${event}: ${hook.run}`, false, run);
37172
+ else run();
37173
+ } else {
37174
+ const call3 = () => hook.fn(hookEvent(config, dirs, report));
37108
37175
  try {
37109
- await settle(hook.fn(hookEvent(config, dirs, report)));
37176
+ await settle(profile?.detailed ? profile.time("hooks", hook.label || `${event} (built in)`, false, call3) : call3());
37110
37177
  } catch (e) {
37111
37178
  throw hook.label === "" && e instanceof Error ? e : new BuildError(`${hook.label}: ${describeThrown(e, dirs.root)}`);
37112
37179
  }
@@ -37310,7 +37377,9 @@ async function passthroughCopy(config, dirs, extra) {
37310
37377
  }
37311
37378
  }
37312
37379
  sameDestinations(jobs, dirs);
37313
- const stats = { copied: 0, unchanged: 0, bytes: 0, paths: jobs.map(([, to]) => to) };
37380
+ const renamed = jobs.filter(([, to]) => config.renamedCopies.has(to)).map(([, to]) => config.renamedCopies.get(to));
37381
+ if (renamed.length) jobs.splice(0, jobs.length, ...jobs.filter(([, to]) => !config.renamedCopies.has(to)));
37382
+ const stats = { copied: 0, unchanged: 0, bytes: 0, paths: [...jobs.map(([, to]) => to), ...renamed] };
37314
37383
  const folders = /* @__PURE__ */ new Map();
37315
37384
  const failed = [];
37316
37385
  let next = 0;
@@ -37406,4 +37475,4 @@ export {
37406
37475
  runCommand,
37407
37476
  OUTPUT_LIST
37408
37477
  };
37409
- /*! For license information please see chunk-DELWRJAO.js.LEGAL.txt */
37478
+ /*! For license information please see chunk-HNG372DW.js.LEGAL.txt */
@@ -5,32 +5,30 @@ import {
5
5
  } from "./chunk-3GYLOC6Y.js";
6
6
  import {
7
7
  findConfig
8
- } from "./chunk-R7K3D5W5.js";
9
- import "./chunk-7XLK2GEG.js";
10
- import "./chunk-NKXEPHRZ.js";
8
+ } from "./chunk-P2TRR6XK.js";
9
+ import "./chunk-ERNVEZOK.js";
10
+ import "./chunk-MDB3D3LP.js";
11
11
  import {
12
12
  VERSION
13
13
  } from "./chunk-AD3HAW3W.js";
14
- import "./chunk-DDV6JEC2.js";
15
- import "./chunk-NCWFYT74.js";
14
+ import "./chunk-BXARVN5Z.js";
15
+ import "./chunk-IOXCGMSF.js";
16
16
  import "./chunk-FVZ5JBRI.js";
17
- import "./chunk-HPXAZ2HU.js";
17
+ import "./chunk-DNWA7WNO.js";
18
18
  import "./chunk-UU43WIZG.js";
19
- import "./chunk-76NTVE34.js";
19
+ import "./chunk-RFNLZM7W.js";
20
20
  import "./chunk-CMUWRPSQ.js";
21
21
  import {
22
22
  TABLE,
23
23
  TomlError,
24
+ compareText,
25
+ isDir,
26
+ isFile,
24
27
  isPlainObject,
25
28
  readToml,
26
29
  red,
27
30
  tomlReason
28
- } from "./chunk-GRWMGC7D.js";
29
- import {
30
- compareText,
31
- isDir,
32
- isFile
33
- } from "./chunk-VJWQSYEG.js";
31
+ } from "./chunk-JFPLNHEQ.js";
34
32
  import "./chunk-I3PS26CI.js";
35
33
 
36
34
  // src/import.ts
@@ -8,7 +8,7 @@ import {
8
8
  globProblem,
9
9
  globToRegExp,
10
10
  isGlob
11
- } from "./chunk-HPXAZ2HU.js";
11
+ } from "./chunk-DNWA7WNO.js";
12
12
  import {
13
13
  ISSUES_URL,
14
14
  SOMETHING_LARGE
@@ -16,11 +16,12 @@ import {
16
16
  import {
17
17
  describeThrown,
18
18
  settle
19
- } from "./chunk-76NTVE34.js";
19
+ } from "./chunk-RFNLZM7W.js";
20
20
  import {
21
21
  BuildError,
22
22
  Diagnostics,
23
23
  bail,
24
+ comparePaths,
24
25
  context,
25
26
  isPlainObject,
26
27
  loadStaticDataFile,
@@ -29,10 +30,7 @@ import {
29
30
  readText,
30
31
  warn,
31
32
  warning
32
- } from "./chunk-GRWMGC7D.js";
33
- import {
34
- comparePaths
35
- } from "./chunk-VJWQSYEG.js";
33
+ } from "./chunk-JFPLNHEQ.js";
36
34
 
37
35
  // src/engines/markdown.ts
38
36
  import { Buffer as Buffer2 } from "node:buffer";
@@ -351,7 +349,7 @@ var WasmMarkdown = class {
351
349
  let text = template.body;
352
350
  for (const name2 of template.engines) {
353
351
  const engine = engines.get(name2);
354
- const ctx = { name: template.name, inputPath: template.path, cacheKey: `${template.name}#${name2}` };
352
+ const ctx = { name: template.name, inputPath: template.path, cacheKey: `${template.name}#${name2}`, kind: "hook" };
355
353
  let out;
356
354
  try {
357
355
  out = engine.render(text, hookData, ctx);