hexo-theme-volantis
Version:
Elegant and powerful theme for Hexo.
12 lines (8 loc) • 448 B
JavaScript
/* global hexo */
// 将 standalone <p><img></p> 包裹为 .img-wrap 容器
const imgRegex = /<p><img src="(.*?)" alt="(.*?)"\/><\/p>/g;
const imgReplacement = '<div class="img-wrap"><div class="img-bg"><img class="img" src="$1" alt="$2"\/><\/div><span class="image-caption">$2<\/span><\/div>';
hexo.extend.filter.register('after_post_render', function(data) {
data.content = data.content.replace(imgRegex, imgReplacement);
return data;
});