@rogerpence/rp-utils
    Preparing search index...

    Function writeMarkdownFile

    • 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.

      Parameters

      • parsedMarkdown: ParsedMarkdown

        Object containing frontmatter and content to write

      • outputFilename: string

        Path where the markdown file should be written

      Returns Promise<void>

      Promise that resolves when file is successfully written

      Error if file write fails

      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.

      Write content-only markdown

      await writeMarkdownFile(
      { frontMatter: {}, content: "# Just content" },
      "simple.md"
      );