Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Shenlin
/
markdown-view
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
lintry
2018-02-23 17:11:27 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0c006d77bbe84da2a031acb6c7d565359bfade79
0c006d77
1 parent
d33daf7e
调整在线模式下css的资源根路径处理
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
6 deletions
lib/md-action.js
lib/view-markdown.js
package.json
server.js
src/index.ejs
lib/md-action.js
View file @
0c006d7
...
...
@@ -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
)
});
...
...
lib/view-markdown.js
View file @
0c006d7
...
...
@@ -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
()
});
...
...
package.json
View file @
0c006d7
...
...
@@ -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"
},
...
...
server.js
View file @
0c006d7
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'
));
...
...
src/index.ejs
View file @
0c006d7
...
...
@@ -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 %>'
>
...
...
Please
register
or
login
to post a comment