You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Hydro/module/wiki/handler.js

29 lines
787 B
JavaScript

5 years ago
const { Route, Handler } = global.Hydro.service.server;
5 years ago
const { NotFoundError } = global.Hydro.error;
// eslint-disable-next-line import/no-unresolved
const pages = require('./__build.json');
5 years ago
5 years ago
class WikiHandler extends Handler {
async get({ name }) {
if (!pages[name]) throw new NotFoundError(name);
const contents = pages[name];
5 years ago
const path = [
['Hydro', '/'],
['wiki', '/wiki'],
5 years ago
[`wiki_${name}`, null],
5 years ago
];
5 years ago
this.response.body = {
path, contents, page_name: `wiki_${name}`,
};
this.response.template = 'wiki.html';
5 years ago
}
}
async function apply() {
5 years ago
Route('/wiki/:name', module.exports.WikiHandler);
5 years ago
}
global.Hydro.handler.wiki = module.exports = {
5 years ago
WikiHandler, apply,
5 years ago
};