Absolute or relative path to the markdown file
Promise resolving to ParseResult with success/failure information
Parse a markdown file
const result = await parseMarkdownFile('./posts/article.md');
if (result.success) {
console.log('Title:', result.data.frontMatter.title);
console.log('Content length:', result.data.content.length);
} else {
console.error(`Parse failed: ${result.filename}`);
console.error(`Error: ${result.error}`);
}
Parses a markdown file with YAML frontmatter.
Extracts frontmatter delimited by
---markers at the beginning of the file and parses it as YAML. The remaining content is returned as plain text. Returns a Result type with either success (parsed data) or failure (error details).This function converts string dates in the format 'yyyy-dd-dd' to Date data types.