快速开始
安装
npm install vuepress@2.0.0-rc.31 vuepress-theme-githubvuepress 是 peerDependency。主题针对 2.0.0-rc.31 测试。
配置
// docs/.vuepress/config.js
import { viteBundler } from '@vuepress/bundler-vite'
import { defineUserConfig } from 'vuepress'
import { githubTheme } from 'vuepress-theme-github'
export default defineUserConfig({
bundler: viteBundler(),
title: '我的项目',
theme: githubTheme({
repo: 'https://github.com/you/your-repo',
navbar: [
{ text: '指南', link: '/guide/' },
{ text: '博客', link: '/blog/' },
],
sidebar: {
'/guide/': ['/guide/README.md', '/guide/setup.md'],
},
}),
})命令
npm run docs:dev # 构建主题,然后启动 dev server
npm run docs:build # 构建主题,然后构建生产站点目录结构
docs/
├── .vuepress/
│ └── config.js
├── posts/ # 博客文章,一篇一个 markdown 文件
├── guide/
│ └── README.md
└── README.md # 首页(frontmatter 里写 `home: true`)posts/ 下的页面会被自动收集:主题生成博客列表、每个标签一个页面、标签总览与归档。 见博客。
1
安装依赖
加入
vuepress 与 vuepress-theme-github。2
创建配置
把
.vuepress/config.js 指向 githubTheme。3
添加内容
写 markdown。落地页设置
home: true。4
启动 dev server
vuepress dev docs