Building this site with Bun + React
2 min read
Why This Stack
The bar for choosing tools is simple: the least moving parts, the fastest feedback.
- Bun acts as both runtime and bundler; one command to run, zero config.
- React 19 + shadcn/ui keeps me from writing buttons and cards from scratch.
- Tailwind CSS v4 defines the theme with CSS variables; dark mode is almost free.
The Content Pipeline
The site is fully static (deployed to GitHub Pages), and every post is an MDX file:
src/content/<category>/<slug>.<lang>.mdx
The build script scripts/build-content.ts processes each post:
- Parse frontmatter with
gray-matter(title, date, tags, excerpt). - Compile Markdown + JSX to React elements with
@mdx-js/mdx'sevaluateSync. - Render to a static HTML string with
react-dom/server'srenderToStaticMarkup. - Generate anchor ids with
rehype-slugand collect headings into a TOC. - Apply syntax highlighting with
rehype-highlight. - Write everything into
src/generated/content.tsfor the frontend to import.
Syntax Highlighting
function computeReadingTime(text: string): number {
const words = text.replace(/\s+/g, " ").trim().split(" ").length;
return Math.max(1, Math.round(words / 200));
}
Gotchas Hit Along the Way
@types/gray-matterdoes not exist on npm; gray-matter ships its own types.- Running the shadcn CLI via
npxcrashes on a missing@ts-morph/common; using the localbun x shadcnworks. - The Tooltip component from shadcn requires a wrapping
TooltipProvider.
Summary
The payoff: content written in Markdown, UI drawn in React, single-pass build, fully static output.
Also available in
A
@asdukwGitHub
Comments
Loading comments…
