mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 17:46:28 +08:00
使用url()来构建url
This commit is contained in:
1 parent
0efac48bde
commit
86f67a0ec3
61 files changed
+262
-275
No files matched your search
@@ -2,23 +2,23 @@ const { Route, Handler } = require('../service/server');
|
||||
const { NotFoundError } = require('../error');
|
||||
|
||||
class WikiHandler extends Handler {
|
||||
async get({ name }) {
|
||||
if (!global.Hydro.wiki[name]) throw new NotFoundError(name);
|
||||
const contents = global.Hydro.wiki[name];
|
||||
async get({ name: page }) {
|
||||
if (!global.Hydro.wiki[page]) throw new NotFoundError(page);
|
||||
const contents = global.Hydro.wiki[page];
|
||||
const path = [
|
||||
['Hydro', '/'],
|
||||
['wiki', '/wiki'],
|
||||
[`wiki_${name}`, null],
|
||||
[`wiki_${page}`, null],
|
||||
];
|
||||
this.response.body = {
|
||||
path, contents, page_name: `wiki_${name}`,
|
||||
path, contents, page_name: `wiki_${page}`,
|
||||
};
|
||||
this.response.template = 'wiki.html';
|
||||
}
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/wiki/:name', WikiHandler);
|
||||
Route('wiki', '/wiki/:page', WikiHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.wiki = module.exports = apply;
|
||||
Reference in new issue
Block a user