Sota Misaki Writing

Direct Markdown Access for Blog Posts

April 29, 2026

I added a small but useful improvement to this site: each blog post can now be accessed directly as a Markdown file by appending .md to its URL.

This means a single post now has two representations:

For example:

The .md response includes both frontmatter and body content, so it can be reused in external tools, scripts, and feed-like integrations without scraping HTML.

How it works (light version)

I added an API-style route at src/pages/blog/[slug].md.ts. At build time, Astro reads post entries from the content collection (getCollection("posts")) and generates one .md route per slug.

When a request comes in:

  1. the route finds the matched post data
  2. it converts metadata into frontmatter text
  3. it appends the original Markdown body
  4. it returns everything with Content-Type: text/markdown

So instead of reverse-engineering rendered HTML, tools can consume the post in its original writing format.

Why this is useful

Direct Markdown access is convenient for:

In addition to blog posts, the same .md access pattern is available for project entries.