mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
Hello Typescript!
This commit is contained in:
1 parent
c9b6412527
commit
ba03d7a7bf
98 files changed
+3186
-2616
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { NotFoundError } from '../error';
|
||||
import { Route, Handler } from '../service/server';
|
||||
|
||||
class WikiHandler extends Handler {
|
||||
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_${category}`, null],
|
||||
[`wiki_${category}_${page}`, null],
|
||||
];
|
||||
this.response.body = {
|
||||
path, contents, page_name: `wiki_${category}_${page}`,
|
||||
};
|
||||
this.response.template = 'wiki.html';
|
||||
}
|
||||
}
|
||||
|
||||
export async function apply() {
|
||||
Route('wiki', '/wiki/:page', WikiHandler);
|
||||
Route('wiki_with_category', '/wiki/:category/:page', WikiHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.wiki = apply;
|
||||
Reference in new issue
Block a user