mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
更新wiki
This commit is contained in:
1 parent
d7c9b695b0
commit
62ac2f52c9
8 files changed
+42
-24
No files matched your search
@@ -2,16 +2,17 @@ const { Route, Handler } = require('../service/server');
|
||||
const { NotFoundError } = require('../error');
|
||||
|
||||
class WikiHandler extends Handler {
|
||||
async get({ page }) {
|
||||
if (!global.Hydro.wiki[page]) throw new NotFoundError(page);
|
||||
const contents = global.Hydro.wiki[page];
|
||||
async get({ category = 'wiki', page }) {
|
||||
if (!global.Hydro.wiki[category]) throw new NotFoundError(category);
|
||||
if (!global.Hydro.wiki[category][page]) throw new NotFoundError(category, page);
|
||||
const contents = global.Hydro.wiki[category][page];
|
||||
const path = [
|
||||
['Hydro', 'homepage'],
|
||||
['wiki', null],
|
||||
[`wiki_${page}`, null],
|
||||
[`wiki_${category}`, null],
|
||||
[`wiki_${category}_${page}`, null],
|
||||
];
|
||||
this.response.body = {
|
||||
path, contents, page_name: `wiki_${page}`,
|
||||
path, contents, page_name: `wiki_${category}_${page}`,
|
||||
};
|
||||
this.response.template = 'wiki.html';
|
||||
}
|
||||
@@ -19,6 +20,7 @@ class WikiHandler extends Handler {
|
||||
|
||||
async function apply() {
|
||||
Route('wiki', '/wiki/:page', WikiHandler);
|
||||
Route('wiki_with_category', '/wiki/:category/:page', WikiHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.wiki = module.exports = apply;
|
||||
Reference in new issue
Block a user