Minimal black & white personal blog built with VitePress 2.0, migrated from Hugo. The design is quiet, restrained, and content‑first.
- programmer minimalism: content first, UI second
- black & white: calm, notebook‑like reading experience
- lightweight typography: light headings with generous whitespace
- monospace for atmosphere: use monospace mainly to create a technical‑journal feeling, not to shout “this is a UI control”
- Framework: VitePress 2.0 (alpha)
- UI: Vue 3 + Pinia + TailwindCSS v4
- Styling: custom theme + Tailwind v4 utilities
- Code highlight: Shiki (
github-light-high-contrast/one-dark-pro)
- content
- markdown with math (MathJax), footnotes, and code blocks with line numbers
- categories, tags, optional series
- draft workflow + scheduled publishing
- ux
- responsive layout
- local search with custom rendering
- clean urls + auto‑generated sitemap
Posts live under posts/ and are organized by category. Allowed category values in frontmatter:
- algorithm – data structures and algorithms
- contest – algorithm contest solutions
- tips – coding tips and experience
- frontend – frontend development and engineering practice
- backend – backend and server development
- math – math notes
- notes – reading notes and excerpts
- essay – personal thoughts and essays
example frontmatter:
---
date: 2024-01-01 12:00:00 +08:00
title: Article Title
category: frontend # must be one of the predefined categories
tags: [tag1, tag2]
series: vitepress-blog # optional
outline: deep # optional: show nested headers in sidebar
draft: true # optional: exclude from listing / production
---- Draft location:
posts/drafts/<category>/- Drafts are visible in development (
pnpm dev) - Drafts are excluded from production builds
- Drafts are visible in development (
- Create a draft or post
pnpm new <category>/<filename>
# e.g. pnpm new algorithm/kmp-algorithm
# create draft
pnpm new drafts/<category>/<filename>- Publish a draft
# publish with current date
pnpm pub <category>/<filename>
# publish with specific (or future) date
pnpm pub <category>/<filename> --date 2024-12-25Posts with future dates are visible during development but excluded from production until the date passes.
For interactive demos there are two main components, with different directory layouts and build flows:
HtmlDemo: based on standalone demo directories next to each article, mirrored as‑is topublic/demos, supporting multiple files (index.html,style.css,script.js, etc.)VueDemo: based on a singleApp.vueper demo directory, compiled byvueDemoPluginintodemo.js/demo.css/index.htmlandoutput.json
HTML demos live next to the article that uses them, with an article‑name directory that contains one or more demo directories:
posts/<category>/
├── <post-name>.md # article
└── <post-name>/ # demos directory (for this article)
└── <demo-name>/ # individual HTML demo
├── index.html # required (entry)
├── style.css # optional
├── script.js # optional
└── output.json # auto-generated (code tabs)
Usage in Markdown:
<HtmlDemo name="demo1" height="220px" />Build pipeline:
htmlDemoPluginscansposts/for directories that contain anindex.html, and generates anoutput.jsonfile for each demo- it then mirrors the whole
posts/directory (excluding.mdfiles) intopublic/demos/ - at runtime,
HtmlDemouses the current route andnameto compute/demos/<post-path>/<name>/, and loads:/demos/.../index.html?theme=<dark|light>into an iframe/demos/.../output.jsonto render the code tabs
Styling has two modes:
- use shared blog theme (recommended)
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="/demo-base.css" />
<link rel="stylesheet" href="./style.css" />
<script src="/demo-theme.js"></script>
</head>
<body>
<!-- demo content -->
</body>
</html>demo-base.cssprovides reset + dark/light theme variables + base layoutdemo-theme.js:- reads the initial theme from the
?theme=dark|lightURL parameter - supports
postMessagemessages{ type: 'request-theme' }/{ type: 'theme', isDark }for dynamic theme sync
- reads the initial theme from the
- fully custom styles (special cases)
<!doctype html>
<html>
<head>
<!-- no demo-theme.js: you own the entire look -->
<style>
body {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
</style>
</head>
<body>
<!-- demo content -->
</body>
</html>Best for one‑off visual experiments that should not follow the blog theme at all.
VueDemo uses demo directories that only contain an App.vue. You do not hand‑write index.html / demo.js / demo.css – they are generated by vueDemoPlugin.
Directory structure (using the css-upgrade article as an example):
posts/frontend/
├── css-upgrade.md
└── css-upgrade/
├── field-sizing/ # a Vue demo
│ └── App.vue # source (the only file you write)
├── scroll-snap-events/
│ └── App.vue
└── ... # other Vue demos
Usage in Markdown:
<VueDemo name="field-sizing" />
<VueDemo name="scroll-snap-events" height="400px" />Build pipeline:
vueDemoPluginlooks underposts/for directories that contain anApp.vueand treats each as a Vue demo directory- each demo directory is compiled to a matching location under
public/demos/, for example:
posts/frontend/css-upgrade/scroll-snap-events/ # source
→ public/demos/frontend/css-upgrade/scroll-snap-events/
├── index.html # mount point + includes demo.css / demo.js
├── demo.js # compiled from App.vue + createApp mount
├── demo.css # from the <style> section
└── output.json # highlighted source for App.vue only
Runtime behavior:
VueDemocomputes/demos/.../<name>/from the current route +name, same asHtmlDemo- the iframe loads
/demos/.../<name>/index.html?theme=<dark|light> - theme is synced with
demo-theme.jsviapostMessage, and demos can send{ type: 'demo-height', height }to report their height soVueDemocan auto‑adjust the panel (unlessheightis explicitly passed)
when to use what
- use
HtmlDemofor “pure HTML/CSS/JS” components, visual experiments, multi‑file demos, or when you need full control overindex.html - use
VueDemowhen you primarily care about interactive logic, state, and reusing Vue ecosystem features (ref,computed, component composition, etc.)
# install dependencies
pnpm install
# development server (http://localhost:5173)
pnpm dev
# production build
pnpm build
# preview production build
pnpm preview
# lint
pnpm lint
pnpm lint:fix├── .vitepress/ # VitePress config & custom theme
│ ├── theme/ # Vue 3 components, layout, store
│ └── config.ts # VitePress site config
├── posts/ # Blog content
│ ├── algorithm/
│ ├── contest/
│ ├── tips/
│ ├── frontend/
│ ├── backend/
│ ├── math/
│ ├── notes/
│ ├── essay/
│ └── drafts/ # drafts, dev only
├── public/ # static assets (avatar, demo-base.css, etc.)
├── config/ # category and other configs
└── package.json
MIT