lintry

调整在线模式下css的资源根路径处理

......@@ -54,7 +54,8 @@ function MdAction (alias_name, md_path) {
return next();
}
let html = viewer.render(urls[1], query.t);
let resource_base = req.original_uri.base || '';
let html = viewer.render(urls[1], query.t, resource_base);
res.send(html)
});
......
......@@ -29,9 +29,11 @@ class ViewMarkdown {
* 渲染文件
* @param filename 文件名,绝对路径
* @param theme 主题
* @param resource_base 资源根路径
* @return {string}
*/
render (filename, theme) {
render (filename, theme, resource_base) {
resource_base = resource_base || '';
const options = this.options;
//默认md
if (!filename || filename.match(/.+\/$/)) {
......@@ -56,7 +58,8 @@ class ViewMarkdown {
let html = ejs.render(template, {
tittle,
theme,
content
content,
resource_base
}, {
root: process.cwd()
});
......
......@@ -25,6 +25,7 @@
"github-markdown-css": "^2.10.0",
"juice": "^4.2.2",
"kml-customize": "git+ssh://git@gitlab.kmlab.com/comm/customize.git#1.0.0",
"kml-original-url-mw": "git+ssh://git@gitlab.kmlab.com/comm/original-url-mw.git#1.0.0",
"markdown-it": "^8.4.0",
"markdown-it-github-toc": "^3.2.4"
},
......
const express = require('express');
const app = express();
const original_url_mw = require('kml-original-url-mw');
const config = require('./init/config');
// 解析原始请求url
app.use(original_url_mw());
//markdown主题
app.use(express.static(__dirname + '/themes'));
......
......@@ -6,8 +6,8 @@
<%= tittle %>
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/markdown.css">
<link rel="stylesheet" href="<%= '/' + theme + '/' + theme + '.css' %>">
<link rel="stylesheet" href="<%= resource_base + '/markdown.css'%>">
<link rel="stylesheet" href="<%= resource_base + '/' + theme + '/' + theme + '.css' %>">
</head>
<body>
<div class='markdown <%= theme %>'>
......