filter.js
This commit is contained in:
parent
ad97d0ee80
commit
b9751f6d6f
11
scripts/filter.js
Normal file
11
scripts/filter.js
Normal file
@ -0,0 +1,11 @@
|
||||
// 替换markdown中图片路径的正则
|
||||
const mdImageRegex = /\]\s*\((?=(?!http).*?\))/gi
|
||||
// 替换所有HTML标签的正则
|
||||
hexo.extend.filter.register('before_post_render', function(article){
|
||||
// article.raw 是原始的文件内容
|
||||
// article.content 是处理过代码块语法高亮的内容
|
||||
if(hexo.config.picture_cdn) {
|
||||
article.content = article.content.replace(mdImageRegex, `](${hexo.config.picture_cdn}`)
|
||||
}
|
||||
return article
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user