filter.js

This commit is contained in:
朱进禄 2022-03-14 16:26:12 +08:00
parent ad97d0ee80
commit b9751f6d6f

11
scripts/filter.js Normal file
View 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
})