This commit is contained in:
syuilo 2018-04-13 12:05:24 +09:00
parent f3c4152a68
commit b099ad2a30
4 changed files with 18 additions and 10 deletions

View file

@ -2,20 +2,26 @@
* Docs
*/
import * as path from 'path';
import ms = require('ms');
import * as Router from 'koa-router';
import * as send from 'koa-send';
const docs = path.resolve(`${__dirname}/../../client/docs/`);
const docs = `${__dirname}/../../client/docs/`;
const router = new Router();
router.get('/assets', async ctx => {
await send(ctx, `${docs}/assets`);
router.get('/assets/*', async ctx => {
await send(ctx, ctx.path, {
root: docs,
maxage: ms('7 days'),
immutable: true
});
});
router.get(/^\/([a-z_\-\/]+?)$/, async ctx => {
await send(ctx, `${docs}/${ctx.params[0]}.html`);
router.get('*', async ctx => {
await send(ctx, `${ctx.params[0]}.html`, {
root: docs
});
});
module.exports = router;
export default router;