chore: improve output on markdown parsing errors

This commit is contained in:
Mathias Schopmans
2024-03-12 14:57:23 +01:00
parent 5cd092e164
commit 858e10b77e

View File

@@ -55,10 +55,15 @@ function convertToHtml(markdown: string): string {
function readMarkdownFile(filePath: string) {
const id = path.basename(filePath, ".md");
const fileContent = fs.readFileSync(filePath, "utf8");
try {
const { data, content } = matter(fileContent);
const body = convertToHtml(content);
return { id, data, body };
} catch (error) {
console.error(`Failed parsing ${filePath}: ${error}`);
process.exit(1);
}
}
// Function to recursively read Markdown files and parse them