Software Engineering ·Meta· 1 min read

Hello, MDX

How this blog works, and a tour of the building blocks every post can use.

Also available in: Srpski

Every post on this site is a plain .mdx file: Markdown for the prose, React components for everything else.

Code#

Fenced blocks are highlighted automatically and get a copy button:

ts
type Post = { slug: string; title: string };

export function byTitle(posts: Post[]) {
  return [...posts].sort((a, b) => a.title.localeCompare(b.title));
}

Need a filename in the title bar? Use the component directly:

config.ts
export const site = {
name: "Milan Pantelić",
languages: ["en", "sr"],
};

Callouts#

Steps#

  1. Create the post
    Add a file under src/content/blog/ named after the language.
  2. Add frontmatter
    Title, date, category, and optional tags.
  3. Translate
    Drop an sr.mdx next to it. Same folder, new language.

Images#

Diagram: post.mdx goes through next build and becomes static HTML in the out folder
Figure 1: How a post travels from MDX to static files.

Everything else#

A collapsible section

Good for long output, optional detours, or spoilers.

MDX

The format behind all of this.

ComponentUse it for
CalloutNotes, tips, warnings
FigureImages with captions
StepsOrdered how-to sequences
LinkCardRich external links