MDX Writing Guide: Every Feature in One Post
A reference post that demonstrates every MDX feature supported by the Labeliy blog — headings, code blocks, images, tables, lists, and more.
This post is a living reference for everyone writing for the Labeliy blog. It uses every Markdown and MDX feature the blog supports, so you can copy-paste from here when you're not sure how something will render.
Getting started#
Posts live in content/blog as .mdx files. Run npm run new-post -- "My Title"
to scaffold a new post with valid frontmatter, then write your content below
the --- block using regular Markdown.
Text formatting#
You can use bold text, italic text, and inline code anywhere in a
paragraph. Links work too — try an internal link back to the blog
index, or an external link that opens in a new tab
automatically.
Images#
Images are responsive and lazy-loaded by default, with a fixed aspect ratio so the page doesn't jump while they load.
Code blocks#
Fenced code blocks get syntax highlighting automatically — no extra setup needed in the post itself.
JavaScript example#
import { getAllPosts } from "@/lib/blog/posts";
export default function Example() {
const posts = getAllPosts();
return posts.map((post) => post.title);
}
Shell example#
npm run new-post -- "How to Print Barcode Labels at Home"
Lists#
Unordered list:
- Frontmatter is validated at build time
- Draft posts are hidden in production
- Tags link to
/blog/tag/[tag]
Ordered list:
- Write your post in
content/blog - Set
draft: falsewhen it's ready - Run
npm run buildto validate and generate the site
Blockquotes#
Good documentation is a love letter to your future self — and to whoever reads your code next.
Tables#
GitHub-flavored tables are supported via remark-gfm:
| Frontmatter field | Required | Notes |
|---|---|---|
title | Yes | Shown as the page <h1> |
description | Yes | Used for meta description & OG |
slug | Yes | Must match the filename |
date | Yes | ISO date, e.g. 2026-06-11 |
updatedAt | No | Used for dateModified in SEO |
tags | No | Powers /blog/tag/[tag] |
coverImage | No | Used for OG image + page header |
draft | No | Defaults to false |
Wrapping up#
That's everything! Head back to the blog index to see how this post looks in the list view, or check the table of contents on the right to jump between sections.