mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
update dep
This commit is contained in:
1 parent
7dc31d02fa
commit
36989b1942
7 files changed
+265
-80
No files matched your search
+14
-5
@@ -1,8 +1,8 @@
|
||||
const
|
||||
path = require('path'),
|
||||
static = require('koa-static'),
|
||||
send = require('koa-send'),
|
||||
nunjucks = require('nunjucks'),
|
||||
hljs = require('hljs'),
|
||||
hljs = require('highlight.js'),
|
||||
MarkdownIt = require('markdown-it'),
|
||||
katex = require('markdown-it-katex'),
|
||||
options = require('../options'),
|
||||
@@ -75,15 +75,24 @@ class Nunjucks extends nunjucks.Environment {
|
||||
this.addGlobal('status', builtin.STATUS);
|
||||
}
|
||||
}
|
||||
const env = new Nunjucks();
|
||||
MIDDLEWARE(static(path.resolve(process.cwd(), '.uibuild')));
|
||||
let env = new Nunjucks();
|
||||
MIDDLEWARE(async (ctx, next) => {
|
||||
let done = false;
|
||||
if (ctx.method === 'HEAD' || ctx.method === 'GET')
|
||||
try {
|
||||
done = await send(ctx, ctx.path, { root: path.resolve(process.cwd(), '.uibuild'), index: 'index.html' });
|
||||
} catch (err) {
|
||||
if (err.status !== 404) throw err;
|
||||
}
|
||||
if (!done) await next();
|
||||
});
|
||||
MIDDLEWARE(async (ctx, next) => {
|
||||
ctx.render_title = str => str;
|
||||
ctx.UIContext = {
|
||||
cdn_prefix: '/',
|
||||
url_prefix: '/'
|
||||
};
|
||||
ctx.preferJson = ctx.request.headers['accept'].includes('application/json');
|
||||
ctx.preferJson = (ctx.request.headers['accept'] || '').includes('application/json');
|
||||
ctx.render = async (name, context) => {
|
||||
ctx.user = ctx.state.user;
|
||||
ctx.translate = str => {
|
||||
|
||||
Reference in new issue
Block a user