基于VuePress搭建知识库

我这边需要搭建一个运维知识库,将项目的方方面面记录下来,方便新手接手运维。

准备环境

  • Nginx 1.19.0
  • VuePress 1.x
  • Minio RELEASE.2022-02-16T00-35-27Z
  • vuepress-theme-vdoing主题

安装VuePress

根据官网步骤即可

复制代码
# 创建目录
mkdir vuepress-starter && cd vuepress-starter

# 初始化
npm init

# 安装VuePress
npm install -D vuepress

# 创建文档 注意这里可能会有问题,需要把文件格式改成UTF-8
mkdir docs && echo '# Hello VuePress' > docs/README.md

# package.json加入脚本
{
  "scripts": {
    "docs:dev": "vuepress dev docs",
    "docs:build": "vuepress build docs"
  }
}

上述即可正式启动一个VuePress

我这边用了vuepress-theme-vdoing主题,也需要安装一下

复制代码
npm install vuepress-theme-vdoing -D

然后在.vuepress/config.js指定主题

复制代码
module.exports = {
  theme: 'vdoing'
}

这边的config.js目前是以下配置

复制代码
module.exports = {
  title: '知识库',
  description: '运维人员知识分享',
  theme: 'vdoing',
  base:'/knowledge/',
  themeConfig: {
    # 导航条
    nav:[
       {text:"首页",link:"/"},
       {text:"第三方平台",link:"/third/"},
       {text:"数据",link:"/data/"},
       {text:"小知识",link:"/technology/"}
    ],
    sidebar: 'structuring'
 }
}

填充内容

修改首页docs\README.md

复制代码
---
home: true
# heroImage: /img/web.png
heroText: 运维知识库
tagline: 记运维过程中的各种知识,帮助每一个过来运维的负责人更快的投入到工作。
# actionText: 立刻进入 →
# actionLink: /web/
# bannerBg: auto # auto => 网格纹背景(有bodyBgImg时无背景),默认 | none => 无 | '大图地址' | background: 自定义背景样式       提示:如发现文本颜色不适应你的背景时可以到palette.styl修改$bannerTextColor变量

features: # 可选的
  - title: 第三方平台
    details: 非本公司平台操作内容
    link: /third/
    imgUrl: /img/ui.png
  - title: 数据
    details: 数据等内容
    link: /data/
    imgUrl: /img/python.png
  - title: 小知识
    details: 技术文档、教程、技巧、总结等文章
    link: /technology/
    imgUrl: /img/other.png

完成首页即可,可以在docs文件夹下写文章内容。

部署

打包

复制代码
vuepress build docs

打包完成生成的静态文件会在.vuepress\dist下面。

即可通过nginx部署,这边我是挂在公司的平台下的

复制代码
location  /knowledge {
    alias /data/knowledge/dist;
    index  index.html index.htm;
    try_files $uri $uri/ /data/knowledge/dist/index.html;
}

知识库需要用到图片服务器,所以这里也用到了minio,minio操作方式特别简单,这里不多介绍。

复制代码
location /public-doc/ {
    proxy_pass http://ip:9000/public-doc/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_send_timeout 60s;
    proxy_read_timeout 60s;
    proxy_connect_timeout 60s;
    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Methods' 'GET,PUT,POST,DELETE,OPTIONS';
    add_header 'Access-Control-Allow-Header' 'Content-Type,*';
}

在这里我是代理了minio的图片服务,需要注意在vuepress中使用存在跨域问题,所以这里需要这样配置。

经过一天的安装配置,正式搭建完成,整个流程比较简单,多看看官网即可解决。之后就是补充内容,完善运维文档。

相关推荐
Murphy_lx11 分钟前
Linux系统--信号(4--信号捕捉、信号递达)陌生概念篇
linux·运维·服务器
weixin_4050233718 分钟前
使用docker 安装部署easy-mock
运维·docker·容器
ZLRRLZ19 分钟前
【Docker】Docker Image(镜像)
运维·docker·容器
焱焱枫1 小时前
Linux疑难杂症诊断利器:深入解析 fuser 命令
linux·运维·服务器
博语小屋1 小时前
Linux进程信号(壹)_产生信号
linux·运维·服务器
养海绵宝宝的小蜗2 小时前
Linux 例行性工作任务(定时任务)知识点总结
linux·运维·服务器
乌萨奇也要立志学C++2 小时前
【Linux】基础IO(二)深入理解“一切皆文件” 与缓冲区机制:从原理到简易 libc 实现
linux·运维·服务器
这周也會开心2 小时前
通过ssh连接GitHub远程仓库
运维·ssh·github
java水泥工3 小时前
旅游管理系统|基于SpringBoot和Vue的旅游管理系统(源码+数据库+文档)
spring boot·vue·计算机毕业设计·java毕业设计·旅游管理系统
草莓熊Lotso3 小时前
Linux 进阶指令实操指南:文件查看、时间管理、搜索压缩全场景覆盖(附高频案例)
linux·运维·服务器