Skip to content

Commit 122881c

Browse files
committed
Update index.ts
1 parent c85ba4d commit 122881c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/remark/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,17 @@ export default function remarkResistogram(options: { dataDir?: string, files?: a
105105
const { dataDir = "data", files = {}, pluginId = 'default' } = options;
106106

107107
return async (tree: any, file: any) => {
108-
const pageText = mdastToPlainText(tree);
108+
// Extract plain text from the AST
109+
let pageText = mdastToPlainText(tree);
110+
111+
// --- Add title from frontmatter if present -------------------------------
112+
// In Docusaurus, parsed frontmatter is available on file.data.frontmatter
113+
const fm = (file.data && (file.data as any).frontmatter) || {};
114+
if (fm.title) {
115+
// Surround with spaces so word-boundary regexes still work
116+
pageText = ` ${fm.title} ${pageText}`;
117+
}
118+
109119
const nodesToProcess: any[] = [];
110120

111121
visit(tree, "paragraph", (node: any, index: number | undefined, parent: any) => {

0 commit comments

Comments
 (0)