🐛 修復POST-META關閉閲讀分鐘和訪問量後,評論量前有分割線的bug

🐛 修復canvas_ribbon透明度變為1再變回預設值bug
🐛 修復當default_cover沒設置時,會出現無圖片的bug
🎨 部分js調整
This commit is contained in:
Jerry
2020-04-02 22:16:01 +08:00
Unverified
parent 5e37ab641a
commit eb11e4afeb
18 changed files with 433 additions and 315 deletions

View File

@@ -1,29 +1,39 @@
'use strict';
/**
* Butterfly
* lazyload
* replace src to data-src
* add class 'lazyload'
*/
const url_for = require('hexo-util').url_for.bind(hexo);
'use strict'
function lazyProcess(htmlContent) {
var bg = url_for(hexo.theme.config.lodding_bg.post);
return htmlContent.replace(/<img(.*?)src="(.*?)"(.*?)>/gi, (str, p1, p2, p3) => {
if (/data-src/gi.test(str)) {
return str;
}
if (/class="(.*?)"/gi.test(str)){
str = str.replace(/class="(.*?)"/gi, (classStr, p1) => {
return classStr.replace(p1, `${p1} lazyload`);
})
const url_for = require('hexo-util').url_for.bind(hexo)
function lazyProcess (htmlContent) {
var bg = url_for(hexo.theme.config.lodding_bg.post)
return htmlContent.replace(
/<img(.*?)src="(.*?)"(.*?)>/gi,
(str, p1, p2, p3) => {
if (/data-src/gi.test(str)) {
return str
}
if (/class="(.*?)"/gi.test(str)) {
str = str.replace(/class="(.*?)"/gi, (classStr, p1) => {
return classStr.replace(p1, `${p1} lazyload`)
})
str = str.replace(p2, `${bg}`)
return str.replace('>', ` data-src="${p2}">`)
}
str = str.replace(p2, `${bg}`)
return str.replace('>', ` data-src="${p2}">`);
return str.replace(p3, ` class="lazyload" data-src="${p2}" ${p3}`)
}
str = str.replace(p2, `${bg}`)
return str.replace(p3, ` class="lazyload" data-src="${p2}" ${p3}`);
});
)
}
var processPost = function(data) {
if (!hexo.theme.config.lazyload.enable) return;
data.content = lazyProcess.call(this, data.content);
return data;
};
var processPost = function (data) {
if (!hexo.theme.config.lazyload.enable) return
data.content = lazyProcess.call(this, data.content)
return data
}
hexo.extend.filter.register('after_post_render', processPost);
hexo.extend.filter.register('after_post_render', processPost)