@matra/site-generation 0.2.0 → 0.2.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.
package/README.ja.md CHANGED
@@ -81,8 +81,14 @@ console.log(`Generated ${outputs.length} files`)
81
81
  (`layout: false`で無効化可能)、diagnosticと相対link解決に使う論理文書pathを
82
82
  指定します。`layouts`と`components`は名前から`{ source, document? }`へのmapです。
83
83
 
84
+ テンプレートとlayoutが`site.documents`を使わない場合、
85
+ `includeDocumentsInTemplates: false`を指定すると空配列を渡し、描画時の全文書一覧のコピーを避けます。
86
+ 既定値は`true`です。Markdown変換、リンク検証、ページのdataとcontent、route、出力管理は変わりません。
87
+
84
88
  両APIはlayout、asset、base path、再利用可能なMatra部品に対応します。
85
89
  Matra部品は`fn Name(props, children) { ... }`で定義し、単一の文書nodeを返します。
90
+ 子要素なしの呼び出しは`Name(props, [])`と書きます。第2引数の省略には、公開済みの
91
+ Core `0.3.1`より新しいruntimeが必要です。
86
92
  設定schema、入力規則、部品の動作、出力保証の詳細は
87
93
  [サイト生成の契約](../../spec/site-generation.ja.md)を参照してください。
88
94
 
package/README.md CHANGED
@@ -83,9 +83,16 @@ data, select a layout (or disable it with `layout: false`), and set the
83
83
  logical document path used for diagnostics and relative links. `layouts` and
84
84
  `components` map names to `{ source, document? }` objects.
85
85
 
86
+ When templates and layouts do not use `site.documents`, set
87
+ `includeDocumentsInTemplates: false` to pass them an empty array and avoid copying
88
+ the full document list during rendering. The default is `true`. Markdown conversion,
89
+ link validation, page data and content, routes, and output management are unaffected.
90
+
86
91
  Both APIs support layouts, assets, a base path, and reusable Matra components.
87
92
  Matra components are defined as `fn Name(props, children) { ... }` and return
88
- one document node. See the [site-generation contract](../../spec/site-generation.md)
93
+ one document node. Use `Name(props, [])` when there are no children; omitting the
94
+ second argument requires a newer Core runtime than the published `0.3.1`. See the
95
+ [site-generation contract](../../spec/site-generation.md)
89
96
  for the complete configuration schema, input rules, component behavior, and
90
97
  output guarantees.
91
98
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matra/site-generation",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Declarative static site generation for Matra",
5
5
  "type": "module",
6
6
  "exports": {
package/src/site.mjs CHANGED
@@ -122,13 +122,15 @@ async function generateLoadedSite({
122
122
  page.content = content
123
123
  page.data = { ...data, ...page.data }
124
124
  }
125
- settings.documents.push({
126
- id: document.id,
127
- path: document.id,
128
- route: page?.route ?? null,
129
- metadata: { ...data, ...metadata },
130
- content,
131
- })
125
+ if (settings.includeDocumentsInTemplates !== false) {
126
+ settings.documents.push({
127
+ id: document.id,
128
+ path: document.id,
129
+ route: page?.route ?? null,
130
+ metadata: { ...data, ...metadata },
131
+ content,
132
+ })
133
+ }
132
134
  }
133
135
  for (const template of [...layouts.values(), ...templates.values()]) {
134
136
  template.bundle = await buildTemplate(template, root)
@@ -353,9 +355,16 @@ function normalizeDirectSite(input) {
353
355
  "templates",
354
356
  "components",
355
357
  "documents",
358
+ "includeDocumentsInTemplates",
356
359
  ]),
357
360
  "generateSite",
358
361
  )
362
+ if (
363
+ Object.hasOwn(options, "includeDocumentsInTemplates") &&
364
+ typeof options.includeDocumentsInTemplates !== "boolean"
365
+ ) {
366
+ throw new TypeError("includeDocumentsInTemplates must be a boolean")
367
+ }
359
368
  if (options.root !== undefined && (typeof options.root !== "string" || !options.root)) {
360
369
  throw new TypeError("root must be a non-empty path")
361
370
  }
@@ -377,6 +386,7 @@ function normalizeDirectSite(input) {
377
386
  .map(key => [key, options[key]]),
378
387
  )
379
388
  const settings = normalizeSettings({ version: 1, site: siteOptions }, root)
389
+ settings.includeDocumentsInTemplates = options.includeDocumentsInTemplates ?? true
380
390
  if (transform) settings.markdown = transform
381
391
  if (settings.outputDirectory === root) throw new Error("site.output must not be the project root")
382
392
  const documentDirectories =