Skip to content
On this page

文档

文档官网使用 VitePress 进行搭建的。

修改文档

拉取安装包

$ git clone ssh://git@g.hz.netease.com:22222/sale_tool/go.git

切换目录

$ cd ./docs

本地预览

$ npm run dev

部署上线

无需打包,直接运行命令即可上线:

$ npm run online

更新文档搜索

文档搜索使用 Algolia 完成,请先完成 注册

爬取页面信息

按照 爬取指引,使用 Python 完成页面爬虫。

config.json 配置文件参考如下:

{
  "index_name": "go_docs",
  "start_urls": [
    "https://go.163.com/f2e/docs/index.html",
    "https://go.163.com/f2e/docs/guide/newcomer.html",
    "https://go.163.com/f2e/docs/guide/guide.html",
    "https://go.163.com/f2e/docs/norm/norm.html",
    "https://go.163.com/f2e/docs/interface/sdk.html",
    "https://go.163.com/f2e/docs/interface/api.html",
    "https://go.163.com/f2e/docs/config/config.html",
    "https://go.163.com/f2e/docs/config/npm.html",
    "https://go.163.com/f2e/docs/config/template.html",
    "https://go.163.com/f2e/docs/config/imagemin.html",
    "https://go.163.com/f2e/docs/config/docs.html",
    "https://go.163.com/f2e/docs/cli/cli.html",
    "https://go.163.com/f2e/docs/template/template.html",
    "https://go.163.com/f2e/docs/template/template-vite3.html",
    "https://go.163.com/f2e/docs/template/template-vite2.html",
    "https://go.163.com/f2e/docs/template/template-static.html",
    "https://go.163.com/f2e/docs/template/template-waibao.html",
    "https://go.163.com/f2e/docs/plugins/index.html",
    "https://go.163.com/f2e/docs/plugins/create-cli.html",
    "https://go.163.com/f2e/docs/plugins/create-template.html",
    "https://go.163.com/f2e/docs/plugins/ui.html",
    "https://go.163.com/f2e/docs/plugins/ui-loading.html",
    "https://go.163.com/f2e/docs/plugins/ui-pixi-loading.html",
    "https://go.163.com/f2e/docs/plugins/ui-f2e-audio.html",
    "https://go.163.com/f2e/docs/plugins/ui-input-verify.html",
    "https://go.163.com/f2e/docs/plugins/ui-video-full.html",
    "https://go.163.com/f2e/docs/plugins/ui-nexus.html",
    "https://go.163.com/f2e/docs/plugins/ui-data-form.html",
    "https://go.163.com/f2e/docs/plugins/ui-open-wxapp.html",
    "https://go.163.com/f2e/docs/plugins/flash.html",
    "https://go.163.com/f2e/docs/plugins/common.html",
    "https://go.163.com/f2e/docs/plugins/getuserinfo.html",
    "https://go.163.com/f2e/docs/plugins/npm.html",
    "https://go.163.com/f2e/docs/km/km.html",
    "https://go.163.com/f2e/docs/km/issues.html"
  ],
  "selectors": {
    "lvl0": "h1",
    "lvl1": "h2",
    "lvl2": "h3",
    "lvl3": "h4",
    "lvl4": "h5",
    "lvl5": "h6",
    "text": "p, ol"
  },
  "nb_hits": 1000
}

修改配置文件

完成数据爬取后,完成 ./docs/.vitepress/config.js 配置修改,参考如下:

algolia: {
  appId: '2N95FTS10F',
  apiKey: '38eedc17215e6c1117831cf6cb538292',
  indexName: 'go_docs'
}

Released under the MIT License.