Docs-server
A server which is used to build a microserver for docs system.
Feature
Notice
Only support second-level directory temporarily.
Your project structure should be like this:
├── doc [custom directory name]
| ├── a.md
| ├── b.md
| ├── c.md
| └── d.md
|
├── docs-server.config.js [define your custom config]
|
├── something.json [additional static route]
|
...
└── package.json
Usage
- You should specify your documents directory.
const send = require('koa-send')
const resolve = require('path').resolve
module.exports = {
docsPath: 'doc',
routes: [
{
path: 'menu',
callback: async (ctx, next) => {
await send(ctx, './menu.json', {
root: resolve(__dirname, './')
})
}
},
{
path: 'something',
callback: async (ctx, next) => {
await send(ctx, './something.json', {
root: resolve(__dirname, './')
})
}
}
]
}
- Import module and run it
const DocsServer = require('docs-server')
const app = new DocsServer()
- ( Optional ) You can specify output path of catalog file ( menu.json ) and server port.
const app = new DocsServer({
catalogOutput: path.resolve(__dirname, './')
port: '3000'
})