🐛 修復文章頁沒有lazyload的bugs

This commit is contained in:
Jerry 2020-08-02 23:29:44 +08:00
parent a7c3a8906a
commit 75f5e991d0

View File

@ -11,5 +11,6 @@ const urlFor = require('hexo-util').url_for.bind(hexo)
hexo.extend.filter.register('after_post_render', data => {
if (!hexo.theme.config.lazyload.enable) return
const bg = hexo.theme.config.lazyload.post ? urlFor(hexo.theme.config.lazyload.post) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs='
return data.content.replace(/(<img.*? src=)/ig, `$1 "${bg}" data-lazy-src=`)
data.content = data.content.replace(/(<img.*? src=)/ig, `$1 "${bg}" data-lazy-src=`)
return data
})