feat: fixed mermaid diagrams

This commit is contained in:
Leyla Becker 2026-02-13 20:57:38 -06:00
parent a6ce214130
commit ffd33049d9
3 changed files with 20 additions and 0 deletions

View file

@ -33,6 +33,15 @@ const getGitModifiedTime = (filePath) => {
return null;
};
const hasMermaidContent = (filePath) => {
try {
const content = fs.readFileSync(filePath, 'utf-8');
return /```mermaid/i.test(content);
} catch (e) {
return false;
}
};
const getTitleFromFilename = (filePath) => {
const basename = path.basename(filePath, '.md');
return basename
@ -115,6 +124,9 @@ module.exports = {
getGitModifiedTime(data.page.inputPath) ??
getFileModifiedTime(data.page.inputPath);
},
mermaid: (data) => {
return hasMermaidContent(data.page.inputPath);
},
permalink: (data) => {
const title = data.title || getTitleFromFilename(data.page.inputPath);
const slug = title.toLowerCase().replace(/\s+/g, '-').replace(/[^\w-]/g, '');