lintry

添加配置

/**
* config
* Created by lintry on 2018/1/9.
*/
const customize = require('kml-customize');
const configure = customize({
"md": {
"base_path": "md",
"default_md": "readme.md",
"theme": "metro-lake"
}
});
//绑定到全局变量
global.config = global.config = configure;
module.exports = configure;
\ No newline at end of file
......@@ -16,6 +16,7 @@
"dependencies": {
"express": "^4.16.2",
"github-markdown-css": "^2.10.0",
"kml-customize": "git+ssh://git@gitlab.kmlab.com/comm/customize.git#1.0.0",
"markdown-it": "^8.4.0"
}
}
......
const express = require('express');
const app = express();
const config = require('./init/config').md;
const mdview = new (require('./lib/mdview')),
path = require('path');
const MARKDOWN_FILE_BASE = path.resolve(process.cwd(), 'md');
const MARKDOWN_FILE_BASE = path.resolve(process.cwd(), config.base_path);
app.use(express.static(__dirname + '/themes'));
app.use(express.static(MARKDOWN_FILE_BASE));
......@@ -12,7 +14,7 @@ app.use(express.static(MARKDOWN_FILE_BASE));
function sendTemplate (filename, theme) {
//默认md
if (!filename || filename.match(/.+\/$/)) {
filename = (filename || '') + 'readme.md'
filename = (filename || '') + config.default_md
}
let file = path.resolve(MARKDOWN_FILE_BASE, filename);
if (!path.parse(file).ext) {
......@@ -20,7 +22,7 @@ function sendTemplate (filename, theme) {
file += '.md'
}
let result = mdview.renderFile(file);
theme = theme || 'metro-lake';
theme = theme || config.theme;
return `
<!DOCTYPE html>
<html>
......