- 安装vuepress,执行
npm install -D vuepress
- 新建文件夹:oc-openapi-docs
- 进入
oc-openapi-docs
执行npm init
,一路回车,完成后会生成package.json
文件 - 修改
package.json
文件,scripts
加入
"dev": "vuepress dev docs",
"build": "vuepress build docs"
oc-openapi-docs
中创建文件夹docs
并进入- 进入
docs
创建.vuepress
和README.md
README.md
内容如下:
---
home: true
heroImage: /hero.png
heroText: 昂立课堂开放平台
tagline: 昂立课堂开放平台
actionText: 开放文档 →
actionLink: /openapi/
features:
- title: 简洁至上
details: 以 Markdown 为中心的项目结构,以最少的配置帮助你专注于写作。
- title: Vue驱动
details: 享受 Vue + webpack 的开发体验,在 Markdown 中使用 Vue 组件,同时可以使用 Vue 来开发自定义主题。
- title: 高性能
details: VuePress 为每个页面预渲染生成静态的 HTML,同时在页面被加载的时候,将作为 SPA 运行。
footer: V1.0
---
- 进入
vuepress
创建文件config.js
,内容如下:
module.exports = {
title: '昂立课堂开放平台',
description: '昂立课堂开放平台',
head: [ // 注入到当前页面的 HTML <head> 中的标签
['link', { rel: 'icon', href: '/logo.jpg' }], // 增加一个自定义的 favicon(网页标签的图标)
],
base: '/', // 这是部署到github相关的配置
markdown: {
lineNumbers: true // 代码块显示行号
},
themeConfig: {
nav: [
{ text: '首页', link: '/' },
{ text: '开放API', link: '/openapi/' },
{ text: '问题答疑', link: '/question/' }
],
sidebar: {
'/openapi/': [
{
title: '修订记录',
sidebarDepth: 2,
path: '/openapi/'
},
{
title: '接入方法',
sidebarDepth: 2,
path: '/openapi/start'
},
{
title: '帐号',
sidebarDepth: false,
children: [
{
title: '帐号创建',
path: '/openapi/user/create'
}
]
},
{
title: '学生',
sidebarDepth: false,
children: [
{
title: '添加帐号为学生',
path: '/openapi/student/add'
},
{
title: '创建帐号并添加为学生',
path: '/openapi/student/create'
}
]
}
]
}
}
};
npm run dev
启动,目前应该可以访问主页
- “开放API”和“问题答疑”对应菜单的文件夹上面没有列出来,下面我给出整个文件日志,方便理解
|_ oc-openapi-docs
|_ docs
|_ .vuepress
|_ public
|_ hero.png //图片
|_ config.js //菜单配置
|_ openapi //业务文档
|_ student
|_ create.md
|_ user
|_ add.md
|_ create.md
|_ start.md
|_ README.md
|_ README.md //首页设置
|_ package.json //依赖包
后面的问题自己摸索吧