@matra/site-generation 0.2.1 → 0.3.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.
package/README.ja.md CHANGED
@@ -92,9 +92,13 @@ Core `0.3.1`より新しいruntimeが必要です。
92
92
  設定schema、入力規則、部品の動作、出力保証の詳細は
93
93
  [サイト生成の契約](../../spec/site-generation.ja.md)を参照してください。
94
94
 
95
+ HTML出力では子要素の配列を再帰的に平坦化するため、条件分岐などが返す配列に`...`は不要です。
96
+ `if`の分岐は最後の式の値だけを返すため、複数の要素を出力するときは配列にまとめます。
97
+ 文書値の配列構造は保持されますが、従来JSONとして表示されていた子配列のHTML出力は変わります。
98
+
95
99
  ## Markdownとブログの出力
96
100
 
97
- 既定のMarkdown変換はそのままです。site-generation `0.2.x`で、サイトに`npm install @matra/markdown-unified@^0.1.0`し、
101
+ 既定のMarkdown変換はそのままです。site-generation `0.3.x`で、サイトに`npm install @matra/markdown-unified@^0.1.2`し、
98
102
  `markdown: "unified"`(ファイル設定では`site.markdown`)を指定すると、
99
103
  YAML frontmatter・GFM・数式(MathML)・見出しID・目次・抜粋を利用できます。
100
104
  目次は`page.data.toc`、抜粋は`page.data.excerpt`から参照できます。
package/README.md CHANGED
@@ -96,10 +96,14 @@ second argument requires a newer Core runtime than the published `0.3.1`. See th
96
96
  for the complete configuration schema, input rules, component behavior, and
97
97
  output guarantees.
98
98
 
99
+ HTML output recursively flattens child arrays, so arrays returned by conditional expressions do not need `...`.
100
+ An `if` branch returns only its last expression, so group multiple elements in an array.
101
+ The document value retains its array structure, but child arrays previously rendered as JSON produce different HTML.
102
+
99
103
  ## Markdown and blog outputs
100
104
 
101
105
  The default Markdown behavior is unchanged. For frontmatter, GFM, math, heading IDs, TOC and
102
- excerpts, use site-generation `0.2.x` and install the [optional unified preset](../markdown-unified/README.md) (`@matra/markdown-unified@^0.1.0`) in the site
106
+ excerpts, use site-generation `0.3.x` and install the [optional unified preset](../markdown-unified/README.md) (`@matra/markdown-unified@^0.1.2`) in the site
103
107
  and set `markdown: "unified"` (under `site` in file configuration).
104
108
  `generateSite({ markdown: async ({ body, document, metadata }) => ..., ... })` also accepts a
105
109
  custom hook returning a node sequence or `{ content: nodes, data: derivedFields }`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matra/site-generation",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Declarative static site generation for Matra",
5
5
  "type": "module",
6
6
  "exports": {
@@ -11,7 +11,7 @@
11
11
  ],
12
12
  "dependencies": {
13
13
  "@matra/core": "^0.3.1",
14
- "@matra/html": "^0.3.1",
14
+ "@matra/html": "^0.4.0",
15
15
  "js-yaml": "^5.2.2",
16
16
  "markdown-it": "^14.3.0"
17
17
  },
package/src/site.mjs CHANGED
@@ -195,7 +195,7 @@ function warnDiscardedNodes(entry) {
195
195
  for (const statement of branch.slice(0, -1)) {
196
196
  if (statement.kind === "expression" && statement.expression.kind === "node") {
197
197
  console.warn(
198
- `${entry.document}: if branch discards <${statement.expression.tag}>. Use ...if with an array to emit multiple nodes.`,
198
+ `${entry.document}: if branch discards <${statement.expression.tag}>. Return an array to emit multiple nodes.`,
199
199
  )
200
200
  }
201
201
  }
@@ -1014,13 +1014,12 @@ function resolveMarkdownLink(href, kind, document, settings, location) {
1014
1014
 
1015
1015
  function assertCompleteDocument(ast, source) {
1016
1016
  if (ast.tag !== "html") throw new TypeError(`${source}: generated page must have one html root`)
1017
- const heads = ast.children.filter(
1018
- child => child && typeof child === "object" && child.tag === "head",
1019
- )
1020
- const bodies = ast.children.filter(
1017
+ const children = ast.children.flat(Infinity)
1018
+ const heads = children.filter(child => child && typeof child === "object" && child.tag === "head")
1019
+ const bodies = children.filter(
1021
1020
  child => child && typeof child === "object" && child.tag === "body",
1022
1021
  )
1023
- if (heads.length !== 1 || bodies.length !== 1 || ast.children.length !== 2) {
1022
+ if (heads.length !== 1 || bodies.length !== 1 || children.length !== 2) {
1024
1023
  throw new TypeError(`${source}: generated html must contain exactly one head and one body`)
1025
1024
  }
1026
1025
  }