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.

Piyush Agrawal
Piyush Agrawal3 min read
MDX Writing Guide: Every Feature in One Post

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.

A retail price tag label produced with Labeliy

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:

  1. Write your post in content/blog
  2. Set draft: false when it's ready
  3. Run npm run build to 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 fieldRequiredNotes
titleYesShown as the page <h1>
descriptionYesUsed for meta description & OG
slugYesMust match the filename
dateYesISO date, e.g. 2026-06-11
updatedAtNoUsed for dateModified in SEO
tagsNoPowers /blog/tag/[tag]
coverImageNoUsed for OG image + page header
draftNoDefaults 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.