🏷️ 更新至3.0.0-RC-1 close #189, close #192, close #223, close #224, close #229, close 232, close #240

This commit is contained in:
Jerry
2020-06-16 18:37:22 +08:00
Unverified
parent 0ad2c01fc9
commit aa8c509b96
93 changed files with 2109 additions and 1648 deletions
+4 -3
View File
@@ -3,18 +3,19 @@
* lazyload
* replace src to data-src
*/
// <figure .+class="[^"]* highlight [^"]*".+>
'use strict'
const urlFor = require('hexo-util').url_for.bind(hexo)
function lazyProcess (htmlContent) {
var bg = hexo.theme.config.lodding_bg.post ? urlFor(hexo.theme.config.lodding_bg.post) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs='
return htmlContent.replace(/(<img .*?src=)/ig, `$1 ${bg} data-src=`)
var bg = hexo.theme.config.lazyload.post ? urlFor(hexo.theme.config.lazyload.post) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs='
return htmlContent.replace(/(<img .*?src=)/ig, `$1 "${bg}" data-src=`)
}
var processPost = function (data) {
if (!hexo.theme.config.lazyload) return
if (!hexo.theme.config.lazyload.enable) return
data.content = lazyProcess.call(this, data.content)
return data
}