开发者文档

This commit is contained in:
undefined committed 2020-05-06 12:40:24 +08:00
1 parent 3e9b074e77
commit e7ce8c1f02
42 files changed
+349 -297

No files matched your search

+14 -20
View File
@@ -1,34 +1,28 @@
const { Route, Handler } = global.Hydro.service.server;
const { NotFoundError } = global.Hydro.error;
// eslint-disable-next-line import/no-unresolved
const pages = require('./__build.json');
class WikiHelpHandler extends Handler {
async get() {
class WikiHandler extends Handler {
async get({ name }) {
if (!pages[name]) throw new NotFoundError(name);
const contents = pages[name];
const path = [
['Hydro', '/'],
['wiki', '/wiki'],
['wiki_help', null],
[`wiki_${name}`, null],
];
this.response.body = { path };
this.response.template = 'wiki_help.html';
}
}
class WikiAboutHandler extends Handler {
async get() {
const path = [
['Hydro', '/'],
['wiki', '/wiki'],
['wiki_about', null],
];
this.response.body = { path };
this.response.template = 'wiki_about.html';
this.response.body = {
path, contents, page_name: `wiki_${name}`,
};
this.response.template = 'wiki.html';
}
}
async function apply() {
Route('/wiki/help', module.exports.WikiHelpHandler);
Route('/wiki/about', module.exports.WikiAboutHandler);
Route('/wiki/:name', module.exports.WikiHandler);
}
global.Hydro.handler.wiki = module.exports = {
WikiHelpHandler, WikiAboutHandler, apply,
WikiHandler, apply,
};