全部学科
NodeJS全栈
nodejs
Python全栈
python
小程序首页
📅 2026-05-23 6 分钟 ✍️ juanwangdev

Vitepress 文档站点

Vitepress 是基于 Vite 的静态站点生成器,专为技术文档设计。

Vitepress 特点

特点说明
基于 Vite极快的开发体验
Markdown文档编写友好
Vue 组件可嵌入 Vue 组件
静态输出SSG 构建产物

安装 Vitepress

Bash
npm add -D vitepress

创建文档结构

JavaScript
docs/
├── index.md          # 首页
├── guide/
│   ├── index.md      # 指南首页
│   └ getting-started.md
│   └ routing.md
└── .vitepress/
    └ config.js       # 配置文件

基础配置

Markdown
// .vitepress/config.js
export default {
  title: 'My Docs',
  description: 'Documentation for my project',
  themeConfig: {
    nav: [
      { text: 'Guide', link: '/guide/' },
      { text: 'API', link: '/api/' }
    ],
    sidebar: {
      '/guide/': [
        {
          text: 'Guide',
          items: [
            { text: 'Getting Started', link: '/guide/getting-started' },
            { text: 'Routing', link: '/guide/routing' }
          ]
        }
      ]
    }
  }
}

Markdown 文档

Bash
# Getting Started

Welcome to the guide!

## Installation

```bash
npm install my-package
\```

## Features

- Feature 1
- Feature 2

嵌入 Vue 组件

Markdown
# Interactive Docs

<CustomComponent />

<script setup>
import CustomComponent from './CustomComponent.vue'
</script>

注意:Vitepress 支持在 Markdown 中使用 Vue 组件。

构建命令

Bash
# 开发模式
vitepress dev docs

# 构建产物
vitepress build docs

# 预览产物
vitepress preview docs

配置 package.json

JSON
{
  "scripts": {
    "docs:dev": "vitepress dev docs",
    "docs:build": "vitepress build docs",
    "docs:preview": "vitepress preview docs"
  }
}

Vitepress vs 其他工具

工具框架特点
VitepressViteVue 组件支持
Next.jsNextReact 组件
DocusaurusReactMeta 产品
Docsify纯前端无构建

要点总结

  • Vitepress 基于 Vite 构建
  • Markdown + Vue 组件支持
  • 配置文件 .vitepress/config.js
  • 构建输出静态站点

📝 发现内容有误?点击此处直接编辑

← 上一篇 Storybook 组件文档
下一篇 → Vitest 单元测试框架
想查看更多题目和详细解析?
小程序提供完整的题库、模拟考试和详细解析
马上就来

长按或扫描二维码,立即体验

扫码体验小程序
马上就来
使用微信扫描二维码
立即体验完整题库