Shipping the simplest blog that works
I almost added gray-matter today.
The plan was the obvious one: drop YAML frontmatter at the top of each
.mdx file, parse it with gray-matter in lib/posts.ts, and call it
done. Then I read the actual Next.js 16 MDX guide bundled in
node_modules/next/dist/docs/ and saw this:
@next/mdxdoes not support frontmatter by default…@next/mdxdoes allow you to use exports like any other JavaScript component.
So instead of YAML, each post starts with:
export const metadata = {
title: "...",
date: "...",
description: "...",
};
The listing page imports the MDX module and reads metadata directly. No
parser. No new dependency. The "frontmatter" is just a JS object the
bundler already knows how to ship.
Why this is better than YAML frontmatter
- One language, not two. No mental switch between YAML rules and JS rules in the same file.
- Type-checkable. I can give
metadataa TypeScript shape later without touching a parser. - No runtime parsing. The bundler does the work at build time.
The lesson
The shortest path to a working blog wasn't the path I learned on other projects. It was the path the framework already supported. Reading the bundled docs first — before reaching for a familiar library — saved a dependency and a chunk of code.
The simplest blog that works is the one that uses what's already in the box.