Building a Custom 'Draft & Drop' MDX Blog Engine

The Gist: We built a custom blogging engine that lets us draft in Notion and publish by simply dropping an MDX file into the repo.
No CMS, no database, no API rate limits. Just Vite for the build, MDX for the content, and a custom Translator layer that turns markdown into high-end React components.
Writing technical tutorials is often a choice between two evils: the "ugly but easy" path (Notion, Google Docs) or the "beautiful but painful" path (hardcoding JSX/HTML).
You want the drag-and-drop ease of Notion for drafting—where you can throw in code blocks, callouts, and images without thinking—but you also want the final output to look like a premium engineering blog, complete with syntax highlighting, interactive components, and pixel-perfect independent typography.
Most developers solve this by wrestling with the Notion API, dealing with rate limits, weird block structures, and "rich text" arrays that break every other week.
We didn't do that. We built something better.
The Problem: The "CMS" Trap
When you're building a personal portfolio, you are the only user. You don't need a headless CMS with five user roles. You don't need a database to store static text.
The friction of opening a code editor, creating a new branch, and writing <p> tags just to fix a typo is enough to kill any blogging habit. On the flip side, using a platform like Medium kills your ability to control the presentation (and you don't own your data).
We needed a middle ground: Draft in Notion, Publish in Code.
The Solution: "Draft & Drop"
Our workflow is dangerously simple:
- Write in Notion: Use the world-class editor we already know.
- Export to Markdown: Or valid MDX.
- Drop into the Repo: Paste it into an
.mdxfile.
That's it. But here is the catch: raw markdown is boring. It doesn't have "Callout Blocks", "Zoomable Images", or "Terminal Windows".
That is where our Translator comes in.
The Secret Sauce: The MDX Translator
We built a custom rendering layer that intercepts standard HTML/Markdown elements and "upgrades" them into supercharged React components on the fly.
We aren't parsing HTML strings with regex (gross). We are utilizing Vite's powerful import.meta.glob feature to load our content, and feeding the MDX provider a precise component mapping.
1. The Content Loader (lib/blog-content.tsx)
First, we tell Vite to hunt down every index.mdx file in our articles directory. This happens at build time, creating a lightning-fast static index.
// Dynamically import all MDX files from the ../content/articles directory
// We use 'eager: true' so they are bundled immediately
const mdxModules = import.meta.glob('../content/articles/*/index.mdx', { eager: true });
2. The Component Mapping (components/mdx-components.tsx)
This is the "Translator". It tells the MDX engine: "Hey, whenever you see a standard element, render THIS React component instead."
// This is the "Translator" Mapping provided to the MDXContext
const components = {
// Map standard headers to our custom typography components
h1: H1,
h2: H2,
// Transform standard quotes into styled architectural blockquotes
blockquote: Blockquote,
// The Heavy Lifters:
// 1. Intercept generic 'pre' blocks to add syntax highlighting & copy buttons
pre: CodeBlock,
// 2. Turn static images into interactive, zoomable media
img: ZoomableImage,
// 3. Custom shortcodes available in MDX
TLDR,
ConceptCard,
StepByStep
};
Why this creates a "WOW" Factor
By mapping pre to our custom CodeBlock, we instantly get:
- Automatic Syntax Highlighting: Powered by
highlight.js. - Mac-style Terminal Chrome: Nice red/yellow/green dots for that "developer" aesthetic.
- Copy to Clipboard: Built-in, because nobody wants to select text manually.
And we didn't have to write a single line of JSX in the article file to get it. We just wrote markdown code fences.
The Ecosystem
Beyond just text, we built a suite of components to make the reading experience top-tier.
1. Auto-Generated Table of Contents
We use a custom hook useHeadings that scans the DOM for h2 and h3 tags after the content loads. It builds a hierarchical tree and even sets up an Intersection Observer to highlight the active section in the sidebar as you scroll.
2. Zoomable Images
Using react-zoom-pan-pinch, generic markdown images are wrapped in a lightbox. You can click to expand, pinch to zoom on mobile, and drag to pan around high-resolution architecture diagrams.
3. Kitchen Sink
Want to see all these components in action? We built specific test page to verify every single component in our arsenal.
See it in Action
Check out the Kitchen Sink to see the full component library, including Alerts, Steps, and Code Blocks, rendered live.
The Stack
We chose a stack that balances performance with developer experience. No heavy frameworks, no hydration hell.
- Vite: For instant dev server starts and lightning-fast HMR.
- React + TypeScript: Type-safe component architecture.
- MDX: The format that bridges the gap between content and code.
- Tailwind CSS: Utility-first styling with a custom design system.
- Lucide React: Beautiful, consistent iconography.
- Wouter: A tiny, zero-dependency router that just works.
Under the Hood
Folder Structure
We keep things semantic. Content lives in content/, code lives in src/.
.
├── content/
│ ├── articles/ # Blog posts (MDX)
│ │ ├── my-post/ # Self-contained folder
│ │ │ ├── index.mdx # The article
│ │ │ └── assets/ # Images specific to this post
│ ├── projects/ # Portfolio projects (tsx)
│ └── resume/ # Resume data (json/tsx)
└── src/
├── components/ # React components (UI kit)
├── lib/ # Utilities & Content Loaders
├── pages/ # Route views
└── styles/ # Global CSS & Tailwind config
The Theme System
We implemented a robust Dark Mode system using CSS variables and Tailwind's dark: modifier.
Instead of hardcoding colors, we use semantic tokens like --background, --foreground, --primary, and --card. This allows the entire site to flip from "Clean White" to "Hacker Dark" instantly, without a single component needing to know which mode is active.
Why Use This?
If you're a developer, you've probably rewritten your portfolio five times. We all do it.
But this architecture is different. It's designed to be forked.
- Zero Database: No Postgres to configure, no Supabase to pay for.
- Zero CMS: No Contentful or Sanity tokens to manage.
- 100% Control: It's just React files. Want to change the font? Edit
index.css. Want a new component? Add it tomdx-components.tsx.
It is the perfect starting point for developers who want a "Portfolio as Code" solution that actually scales with their content.
The Roadmap
The foundation is rock solid. Since we are just ingesting MDX files, the next step is automation.
We plan to hook up an n8n or Make.com workflow that listens for a "Published" status change in Notion, converts the page to Markdown, and opens a Pull Request on GitHub automatically.
Conclusion
This architecture proves that you don't need complex infrastructure to build a world-class blog. You just need to respect your own developer experience.
By building this "Translator", we've removed the friction between "having an idea" and "shipping a beautiful article."
Now, if you'll excuse me, I have some more "Draft & Drop" articles to write.