Docs-server
A server which is used to build a kind of microservices for docs system.
Feature
-
Perform automatic markdown searching and generate correct dynamic routes according to the root path of your project.
-
Support multiple-level documentation routes.
-
Support for specifying additional static resources routes.
-
Support for customizing all docs routes
Installing
yarn add docs-server
npm i docs-server
Usage
const DocsServer = require('docs-server')
const app = new DocsServer()
- ( Optional ) You can specify your custom configuration.
const resolve = require('path').resolve
const DocsServer = require('docs-server')
const app = new DocsServer({
cwd: resolve(__dirname, './'),
dest: resolve(__dirname, './menu.json'),
port: '8800',
extra: [
{
route: '/test',
middleware: async (ctx, next) => {
}
}
],
filter: (origin) => {
const removeShortDate = origin.replace(/\/{0}(\d{6}-)+/g, '')
const removeInitialYear = removeShortDate.replace(/^\d{4}/, '')
const removeRepeat = removeInitialYear.replace(/^\/\S+\//, '')
const removeExtension = removeRepeat.replace(/\.md$/, '')
return `writings/${removeExtension}`
}
})
-
Notice:
-
All options is optional
-
default filter will just remove docs file extension name
-
custom filter MUST return a string type value, and it will be used to only generate docs routes (excluding extra routes
and menu.json
)
-
Test your building
# test your server
curl -v http://localhost:8800 # response from /
curl -v http://localhost:8800/doc/sample # response from /doc/sample
CHANGELOG
CHANGELOG