diff --git a/_config.yml b/_config.yml index 16cf395..d7aaca7 100644 --- a/_config.yml +++ b/_config.yml @@ -459,25 +459,11 @@ google_adsense: # Verification (站長驗證) # -------------------------------------- -# Google Webmaster tools verification setting -# See: https://www.google.com/webmasters/ -google_site_verification: - -# Bing Webmaster tools verification setting -# See: https://www.bing.com/webmaster/ -bing_site_verification: - -# Baidu Webmaster tools verification setting -# See: https://ziyuan.baidu.com/site/ -baidu_site_verification: - -# 360 Webmaster tools verification setting -# see http://zhanzhang.so.com/ -qihu_site_verification: - -# Yandex Webmaster tools verification setting -# see https://webmaster.yandex.com/ -yandex_site_verification: +site_verification: + # - name: google_site_verification + # content: xxxxxx + # - name: baidu_site_verification + # content: xxxxxxx # Beautify/Effect (美化/效果) # -------------------------------------- @@ -828,10 +814,12 @@ pangu: field: site # site/post # Lazyload (圖片懶加載) -# https://github.com/verlok/lazyload +# https://github.com/verlok/vanilla-lazyload lazyload: enable: false - post: /img/loading.gif + field: site # site/post + placeholder: + blur: false # PWA # See https://github.com/JLHwung/hexo-offline diff --git a/layout/includes/head/site_verification.pug b/layout/includes/head/site_verification.pug index cae5742..8947644 100644 --- a/layout/includes/head/site_verification.pug +++ b/layout/includes/head/site_verification.pug @@ -1,14 +1,3 @@ -if theme.google_site_verification - meta(name="google-site-verification" content=theme.google_site_verification) - -if theme.bing_site_verification - meta(name="msvalidate.01" content=theme.bing_site_verification) - -if theme.baidu_site_verification - meta(name="baidu-site-verification" content=theme.baidu_site_verification) - -if theme.qihu_site_verification - meta(name="360-site-verification" content=theme.qihu_site_verification) - -if theme.yandex_site_verification - meta(name="yandex-verification" content=theme.yandex_site_verification) \ No newline at end of file +if theme.site_verification + each item in theme.site_verification + meta(name=item.name content=item.content) \ No newline at end of file diff --git a/layout/includes/mixins/article-sort.pug b/layout/includes/mixins/article-sort.pug index c2f1b5e..01e9ef2 100644 --- a/layout/includes/mixins/article-sort.pug +++ b/layout/includes/mixins/article-sort.pug @@ -11,10 +11,7 @@ mixin articleSort(posts) .article-sort-item(class=no_cover) if article.cover && theme.cover.archives_enable a.article-sort-item-img(href=url_for(article.path) title=title) - if theme.lazyload.enable - img(data-lazy-src=url_for(article.cover) alt=title onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'`) - else - img(src=url_for(article.cover) alt=title onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'`) + img(src=url_for(article.cover) alt=title onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'`) .article-sort-item-info .article-sort-item-time i.far.fa-calendar-alt diff --git a/layout/includes/mixins/post-ui.pug b/layout/includes/mixins/post-ui.pug index 4d8778a..cdf62ee 100644 --- a/layout/includes/mixins/post-ui.pug +++ b/layout/includes/mixins/post-ui.pug @@ -9,10 +9,7 @@ mixin postUI(posts) if post_cover && theme.cover.index_enable .post_cover(class=leftOrRight) a(href=url_for(link) title=title) - if theme.lazyload.enable - img.post_bg(data-lazy-src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.error_img.post_page) + `'` alt=title) - else - img.post_bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.error_img.post_page) + `'` alt=title) + img.post_bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.error_img.post_page) + `'` alt=title) .recent-post-info(class=no_cover) a.article-title(href=url_for(link) title=title)= title .article-meta-wrap diff --git a/layout/includes/page/flink.pug b/layout/includes/page/flink.pug index 456d3b7..f0b088c 100644 --- a/layout/includes/page/flink.pug +++ b/layout/includes/page/flink.pug @@ -13,10 +13,7 @@ each item in i.link_list .flink-list-item a(href=url_for(item.link) title=item.name target="_blank") - if theme.lazyload.enable - img(data-lazy-src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt=item.name ) - else - img(src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt=item.name ) + img(src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt=item.name ) span.flink-item-name= item.name span.flink-item-desc(title=item.descr)= item.descr != page.content diff --git a/layout/includes/pagination.pug b/layout/includes/pagination.pug index 8bb76a9..c50b81a 100644 --- a/layout/includes/pagination.pug +++ b/layout/includes/pagination.pug @@ -15,10 +15,7 @@ if is_post() .prev-post(class=hasPageNext) - var pagination_cover = prev.cover === false ? prev.randomcover : prev.cover a(href=url_for(prev.path)) - if theme.lazyload.enable - img.prev-cover(data-lazy-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of previous post') - else - img.prev-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of previous post') + img.prev-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of previous post') .pagination-info .label=_p('pagination.prev') .prev_info=prev.title @@ -28,10 +25,7 @@ if is_post() - var pagination_cover = next.cover == false ? next.randomcover : next.cover .next-post(class=hasPagePrev) a(href=url_for(next.path)) - if theme.lazyload.enable - img.next-cover(data-lazy-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of next post') - else - img.next-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of next post') + img.next-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of next post') .pagination-info .label=_p('pagination.next') .next_info=next.title diff --git a/layout/includes/post/reward.pug b/layout/includes/post/reward.pug index 0d6a584..41bb3c9 100644 --- a/layout/includes/post/reward.pug +++ b/layout/includes/post/reward.pug @@ -8,9 +8,6 @@ - var clickTo = item.link ? item.link : item.img li.reward-item a(href=url_for(clickTo) target='_blank') - if theme.lazyload.enable - img.post-qr-code-img(data-lazy-src=url_for(item.img) alt=item.text) - else - img.post-qr-code-img(src=url_for(item.img) alt=item.text) + img.post-qr-code-img(src=url_for(item.img) alt=item.text) .post-qr-code-desc=item.text diff --git a/layout/includes/sidebar.pug b/layout/includes/sidebar.pug index 639dd79..88551d7 100644 --- a/layout/includes/sidebar.pug +++ b/layout/includes/sidebar.pug @@ -2,10 +2,7 @@ #menu-mask #sidebar-menus .author-avatar - if theme.lazyload.enable - img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar") - else - img.avatar-img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar") + img.avatar-img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar") .site-data if site.posts.length .data-item.is-center diff --git a/layout/includes/widget/card_author.pug b/layout/includes/widget/card_author.pug index b694bd8..547fec8 100644 --- a/layout/includes/widget/card_author.pug +++ b/layout/includes/widget/card_author.pug @@ -1,10 +1,7 @@ if theme.aside.card_author.enable .card-widget.card-info .card-info-avatar.is-center - if theme.lazyload.enable - img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar") - else - img.avatar-img(src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar") + img.avatar-img(src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar") .author-info__name= config.author .author-info__description!= theme.aside.card_author.description || config.description diff --git a/layout/includes/widget/card_recent_post.pug b/layout/includes/widget/card_recent_post.pug index b207475..60a0e07 100644 --- a/layout/includes/widget/card_recent_post.pug +++ b/layout/includes/widget/card_recent_post.pug @@ -14,10 +14,7 @@ if theme.aside.card_recent_post.enable .aside-list-item(class=no_cover) if post_cover && theme.cover.aside_enable a.thumbnail(href=url_for(link) title=title) - if theme.lazyload.enable - img(data-lazy-src=url_for(post_cover) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'` alt=title) - else - img(src=url_for(post_cover) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'` alt=title) + img(src=url_for(post_cover) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'` alt=title) .content a.title(href=url_for(link) title=title)= title if theme.aside.card_recent_post.sort === 'updated' diff --git a/package.json b/package.json index 8260e35..cd743fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "3.7.1-b1", + "version": "3.7.5-b1", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/scripts/filters/post_lazyload.js b/scripts/filters/post_lazyload.js index c279633..7c02bc9 100644 --- a/scripts/filters/post_lazyload.js +++ b/scripts/filters/post_lazyload.js @@ -8,9 +8,20 @@ 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=' - data.content = data.content.replace(/( { + data.content = lazyload.call(this, data.content) + return data + }) +} \ No newline at end of file diff --git a/scripts/helpers/related_post.js b/scripts/helpers/related_post.js index 24992b4..1e7efd4 100644 --- a/scripts/helpers/related_post.js +++ b/scripts/helpers/related_post.js @@ -41,7 +41,6 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { const limitNum = config.related_post.limit || 6 const dateType = config.related_post.date_type || 'created' const headlineLang = this._p('post.recommend') - const lazySrc = config.lazyload.enable ? 'data-lazy-src' : 'src' relatedPosts = relatedPosts.sort(compare('weight')) @@ -67,9 +66,7 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { relatedPosts[i].title + '">' result += - 'cover' if (dateType === 'created') { diff --git a/source/css/_global/index.styl b/source/css/_global/index.styl index 71fc5f1..9563f7e 100644 --- a/source/css/_global/index.styl +++ b/source/css/_global/index.styl @@ -206,6 +206,15 @@ img &:not([src]) opacity: 0 +// lazyload blur +if hexo-config('lazyload.enable') && hexo-config('lazyload.blur') && !hexo-config('lazyload.placeholder') + img + &[data-lazy-src]:not(.loaded) + filter: blur(10px) brightness(1) + + &[data-lazy-src].error + filter: none + .img-alt margin: -.5rem 0 .5rem color: #858585 diff --git a/source/css/_mode/darkmode.styl b/source/css/_mode/darkmode.styl index da9b673..0005450 100644 --- a/source/css/_mode/darkmode.styl +++ b/source/css/_mode/darkmode.styl @@ -94,11 +94,16 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' .post-outdate-notice, .error-img, #article-container iframe, - img, .gist, .ads-wrap filter: brightness(.8) + img + if hexo-config('lazyload.enable') && hexo-config('lazyload.blur') && !hexo-config('lazyload.placeholder') + filter: blur(0) brightness(.8) + else + filter: brightness(.8) + #aside-content .aside-list > .aside-list-item:not(:last-child) border-bottom: 1px dashed alpha(#FFFFFF, .1) diff --git a/source/img/loading.gif b/source/img/loading.gif deleted file mode 100644 index 46df25a..0000000 Binary files a/source/img/loading.gif and /dev/null differ