Object containing frontmatter and content to write
Path where the markdown file should be written
Promise that resolves when file is successfully written
Write markdown with frontmatter
const document = {
frontMatter: {
title: "My Article",
date: "2025-12-03",
tags: ["typescript", "markdown"]
},
content: "# Hello World\n\nThis is my content."
};
await writeMarkdownFile(document, "./output/article.md");
Creates this file:
---
title: My Article
date: '2025-12-03'
tags:
- typescript
- markdown
---
# Hello World
This is my content.
Writes a ParsedMarkdown object to a file with YAML frontmatter.
Serializes the frontmatter object to YAML format, wraps it in
---delimiters, and combines it with the markdown content before writing to the specified file. If frontmatter is empty, only content is written.