Skip to content

Commit 65ec255

Browse files
committed
2 parents a05e141 + 1d275d4 commit 65ec255

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

dist/remark/index.mjs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,8 @@ function node(value) {
16011601
// src/remark/index.ts
16021602
var import_chalk = __toESM(require_source());
16031603
import { join } from "path";
1604+
import matter from "gray-matter";
1605+
import fs from "fs";
16041606
function mdastToPlainText(root) {
16051607
let out = "";
16061608
const push = (s) => {
@@ -1659,9 +1661,13 @@ function remarkResistogram(options) {
16591661
const { dataDir = "data", files = {}, pluginId = "default" } = options;
16601662
return async (tree, file) => {
16611663
let pageText = mdastToPlainText(tree);
1662-
const fm = file.data && file.data.frontmatter || {};
1663-
if (fm.title) {
1664-
pageText = ` ${fm.title} ${pageText}`;
1664+
try {
1665+
const fileContent = fs.readFileSync(file.path, "utf8");
1666+
const { data: fm } = matter(fileContent);
1667+
if (fm.title) {
1668+
pageText = ` ${fm.title} ${pageText}`;
1669+
}
1670+
} catch (e) {
16651671
}
16661672
const nodesToProcess = [];
16671673
visit(tree, "paragraph", (node2, index, parent) => {

0 commit comments

Comments
 (0)