This commit is contained in:
Jerry
2020-07-16 19:30:54 +08:00
Unverified
parent 5b6e008b84
commit 898cc31c58
93 changed files with 2128 additions and 2151 deletions
+2 -3
View File
@@ -1,9 +1,8 @@
/**
* Butterfly
* lazyload
* replace src to data-src
* replace src to data-lazy-src
*/
// <figure .+class="[^"]* highlight [^"]*".+>
'use strict'
@@ -11,7 +10,7 @@ const urlFor = require('hexo-util').url_for.bind(hexo)
function lazyProcess (htmlContent) {
const 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=`)
return htmlContent.replace(/(<img .*? src=)/ig, `$1 "${bg}" data-lazy-src=`)
}
const processPost = function (data) {
+4
View File
@@ -6,10 +6,14 @@
'use strict'
hexo.extend.filter.register('before_post_render', function (data) {
if (data.top_img && data.top_img.indexOf('/') === -1) data.top_img = data.path + data.top_img
if (data.cover && data.cover.indexOf('/') === -1) data.cover = data.path + data.cover
if (data.cover === false) {
data.randomcover = randomCover()
return data
}
data.cover = data.cover || randomCover()
return data
})