@docubook/flame 1.3.4 → 1.3.5
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/.docu/node/build.ts
CHANGED
|
@@ -112,8 +112,8 @@ async function renderDocsPage(
|
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
const title = (frontmatter.title
|
|
116
|
-
const description =
|
|
115
|
+
const title = (typeof frontmatter.title === "string" ? frontmatter.title : "") || slug || "Docs";
|
|
116
|
+
const description = typeof frontmatter.description === "string" ? frontmatter.description : "";
|
|
117
117
|
const slugParts = slug ? slug.split("/") : [];
|
|
118
118
|
|
|
119
119
|
const page = React.createElement(
|
|
@@ -365,6 +365,8 @@ export class BuildPluginBuilder implements PluginBuilder {
|
|
|
365
365
|
* Each callback receives the **previous** callback's return value (or the
|
|
366
366
|
* original frontmatter for the first). Callbacks that return `undefined` or
|
|
367
367
|
* `null` pass the current value through unchanged.
|
|
368
|
+
* Callbacks that return a non-object (string, number, array) are skipped
|
|
369
|
+
* with a console warning — only plain objects are accepted.
|
|
368
370
|
* Errors inside individual callbacks are caught and logged — the current
|
|
369
371
|
* frontmatter passes through unchanged for that step.
|
|
370
372
|
*
|
|
@@ -381,7 +383,13 @@ export class BuildPluginBuilder implements PluginBuilder {
|
|
|
381
383
|
try {
|
|
382
384
|
const next = await this._transformFrontmatter[i](result, context);
|
|
383
385
|
if (next !== undefined && next !== null) {
|
|
384
|
-
|
|
386
|
+
if (typeof next === "object" && !Array.isArray(next)) {
|
|
387
|
+
result = next;
|
|
388
|
+
} else {
|
|
389
|
+
console.warn(
|
|
390
|
+
`[plugin] transformFrontmatter callback #${i + 1} returned invalid type (expected a plain object), skipping`
|
|
391
|
+
);
|
|
392
|
+
}
|
|
385
393
|
}
|
|
386
394
|
} catch (err) {
|
|
387
395
|
console.error(
|
|
@@ -422,6 +430,10 @@ export class BuildPluginBuilder implements PluginBuilder {
|
|
|
422
430
|
* Callbacks are chained in a waterfall: the return value of one is passed
|
|
423
431
|
* as input to the next. Return `undefined` to pass through unchanged.
|
|
424
432
|
*
|
|
433
|
+
* **Note:** Only plain objects are accepted as return values. Returning
|
|
434
|
+
* a string, number, or array will be silently skipped with a warning.
|
|
435
|
+
* Plugin authors should validate their return values before returning.
|
|
436
|
+
*
|
|
425
437
|
* @param callback - Receives frontmatter object and page context.
|
|
426
438
|
*
|
|
427
439
|
* @example
|
|
@@ -121,8 +121,12 @@ async function renderDocsServerPage(
|
|
|
121
121
|
pathname: string,
|
|
122
122
|
state: ServerState
|
|
123
123
|
): Promise<Response> {
|
|
124
|
-
const title =
|
|
125
|
-
|
|
124
|
+
const title =
|
|
125
|
+
(typeof doc.frontmatter.title === "string" ? doc.frontmatter.title : "") ||
|
|
126
|
+
slug.join("/") ||
|
|
127
|
+
"Docs";
|
|
128
|
+
const description =
|
|
129
|
+
typeof doc.frontmatter.description === "string" ? doc.frontmatter.description : "";
|
|
126
130
|
|
|
127
131
|
const page = React.createElement(
|
|
128
132
|
DocsLayout,
|