-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
46 lines (41 loc) · 964 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var hexoLog = require("hexo-log");
var log =
typeof hexoLog["default"] === "function"
? hexoLog["default"]({
debug: false,
silent: false,
})
: hexoLog({
debug: false,
silent: false,
});
/**
* md文件返回 true
* @param {*} data
*/
function ignore(data) {
// TODO: 好奇怪,试了一下, md返回true, 但却需要忽略 取反!
var source = data.source;
var ext = source.substring(source.lastIndexOf(".")).toLowerCase();
return ["md"].indexOf(ext) > -1;
}
function action(data) {
// <!-- hidden:start -->([\\s\\S]*?)<!-- hidden:end --> --> 空
var regExp = RegExp(
"<!-- hidden:start -->([\\s\\S]*?)<!-- hidden:end -->",
"g"
);
// hexo g
data.content = data.content.replace(regExp, "", "g");
// log.info(`hexo-hidden`);
return data;
}
hexo.extend.filter.register(
"before_post_render",
(data) => {
if (!ignore(data)) {
action(data);
}
},
0
);