安装vitepres
npm add -D vitepress
输入命令安装
npx vitepress init
开始配置
┌ Welcome to VitePress!
│
◇ Where should VitePress initialize the config?
│ ./docs //文档的路径
│
◇ Site title:
│ My Awesome Project //标题
│
◇ Site description:
│ A VitePress Site //描述
│
◆ Theme: //风格
│ ● Default Theme (Out of the box, good-looking docs) //默认
│ ○ Default Theme + Customization // 默认+自定义
│ ○ Custom Theme //自定义
└
目录结构
docs下存放着文档信息和.vitepress的路由配置
部署linux
.vitepress下的base:"/"
server {gzip on;gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;listen 8090; #端口server_name _;index index.html;location / {# content locationroot /home/web/docs; #文档的存放在路径# exact matches -> reverse clean urls -> folders -> not foundtry_files $uri $uri.html $uri/ =404;# non existent pageserror_page 404 /404.html;# a folder without index.html raises 403 in this setuperror_page 403 /404.html;# adjust caching headers# files in the assets folder have hashes filenameslocation ~* ^/assets/ {expires 1y;add_header Cache-Control "public, immutable";}}
}
最后是成果
在线预览 cy-docs
giteelichaoyang/cy-docshttps://gitee.com/Yang_02/cy-docs