@chronova/wiki-agent 1.5.0 → 1.5.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/dist/flatten-wiki.js +18 -3
- package/package.json +1 -1
package/dist/flatten-wiki.js
CHANGED
|
@@ -68,6 +68,19 @@ function extractTitle(content, wikiName) {
|
|
|
68
68
|
}
|
|
69
69
|
return wikiName.replace(/-/g, " ");
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Strips a leading YAML frontmatter block (`---\n...\n---`) from markdown
|
|
73
|
+
* content. GitHub Wiki does not process frontmatter — it renders the YAML
|
|
74
|
+
* as visible text — so the block must be removed before publishing.
|
|
75
|
+
* A single optional newline after the closing `---` is also trimmed so the
|
|
76
|
+
* body starts cleanly. Files without frontmatter are returned unchanged.
|
|
77
|
+
*/
|
|
78
|
+
function stripFrontmatter(content) {
|
|
79
|
+
const match = content.match(/^---\n[\s\S]*?\n---\n?/);
|
|
80
|
+
if (!match)
|
|
81
|
+
return content;
|
|
82
|
+
return content.slice(match[0].length);
|
|
83
|
+
}
|
|
71
84
|
/**
|
|
72
85
|
* Recursively walks the source .wiki/ directory and collects all .md files
|
|
73
86
|
* with their relative paths, excluding metadata and config files.
|
|
@@ -200,9 +213,11 @@ export async function flattenWiki(wikiRoot, outputDir) {
|
|
|
200
213
|
const wikiName = flatFile.replace(/\.md$/, "");
|
|
201
214
|
// Determine the source file's directory relative to .wiki/
|
|
202
215
|
const sourceRelDir = path.dirname(file.relPath) === "." ? "" : path.dirname(file.relPath);
|
|
203
|
-
// Rewrite links
|
|
204
|
-
|
|
205
|
-
|
|
216
|
+
// Rewrite links on the frontmatter-stripped body. GitHub Wiki renders
|
|
217
|
+
// frontmatter as literal text, so strip it before publishing.
|
|
218
|
+
const body = stripFrontmatter(content);
|
|
219
|
+
const rewritten = rewriteLinks(body, sourceRelDir, pathMap);
|
|
220
|
+
// Extract title for sidebar (uses the original content with frontmatter)
|
|
206
221
|
const title = extractTitle(content, wikiName);
|
|
207
222
|
pageInfos.push({ relPath: file.relPath, wikiName, title });
|
|
208
223
|
// Write the file
|