name: vitepress-chapter-management description: Manage VitePress experiment chapters and plugins. Use when adding, reordering, or removing experiment chapters, or when integrating new VitePress plugins into the documentation site.
VitePress Chapter & Plugin Management
Adding a New Chapter
Create the Markdown file in
src/document/following the naming patternchap{XX}_{device}_{topic}.md(e.g.,chap20_router_bgp.md).Create the assets directory alongside the file:
src/document/chap20_router_bgp.assets/.Write the chapter content with this structure:
# {NN}:{Chapter Title}
## Experiment Objectives
## Network Topology
## Experiment Steps
## Command Reference
## Questions
- Register in sidebar — edit
src/.vitepress/config.mts, add an entry to thesidebar['/document/'].itemsarray in the correct position by experiment number:
{ text: '{NN}:{Title}', link: '/document/chap{XX}_{device}_{topic}' },
- Verify: Run
npm run buildto confirm no errors.
Reordering Chapters
Edit the items array order in sidebar['/document/'] inside src/.vitepress/config.mts. The sidebar renders in array order.
Integrating a New Plugin
Install:
npm install {plugin-name}Register the plugin in the appropriate location:
- Vite plugin →
vite.pluginsarray inconfig.mts - Markdown-it plugin →
markdown.config(md)callback inconfig.mts - Config wrapper → wrap
defineConfig(...)(e.g.,withMermaid(...)) - Theme plugin →
src/.vitepress/theme/index.tsviaenhanceApporLayoutslots
- Vite plugin →
Handle SSR if the plugin uses client-side APIs:
- Add to
vite.optimizeDeps.exclude - Add to
vite.ssr.noExternal
- Add to
Localize any user-facing text to Chinese.
Verify: Run
npm run buildandnpm run devto confirm.