Skip to content

Commit

Permalink
chore: improve output on markdown parsing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasschopmans committed Mar 12, 2024
1 parent 5cd092e commit 858e10b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/buildData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
const { data, content } = matter(fileContent);
const body = convertToHtml(content);

return { id, data, body };
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
Expand Down

0 comments on commit 858e10b

Please sign in to comment.