diff --git a/README.md b/README.md index f9d97b54a..54757a8ca 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ ![hexo version](https://img.shields.io/badge/hexo-5.0+-0e83c) ![license](https://img.shields.io/github/license/jerryc127/hexo-theme-butterfly?color=FF5531) +![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/theme-butterfly-readme.png) + Demo: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [MYW](https://immyw.com/) Docs: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/) @@ -80,9 +82,9 @@ npm i hexo-theme-butterfly - [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo) - [x] Multiple Comment System Support - [x] Online Chats (Chatra/Tidio/Daovoice/Gitter/Crisp) -- [x] Web analytics (Baidu Analytics/Google Analytics/Tencent Analytics/CNZZ Analytics) +- [x] Web analytics - [x] Google AdSense -- [x] Webmaster Verification (google/Bing/Baidu/360/Yandex) +- [x] Webmaster Verification - [x] Change website colour scheme - [x] Typewriter Effect: activate_power_mode - [x] Background effects (Canvas ribbon/canvas_ribbon_piao/canvas_nest) @@ -97,6 +99,9 @@ npm i hexo-theme-butterfly ## Screenshots +![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-1.jpg) +![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-2.jpg) +![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-3.jpg) +![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-4.jpg) ![](https://cdn.jsdelivr.net/gh/jerryc127/CDN/img/theme-butterfly-readme-homepage-1.png) - ![](https://cdn.jsdelivr.net/gh/jerryc127/CDN/img/theme-butterfly-readme-homepage-2.png) \ No newline at end of file diff --git a/README_CN.md b/README_CN.md index 659d1ba25..672126914 100644 --- a/README_CN.md +++ b/README_CN.md @@ -12,6 +12,8 @@ ![hexo version](https://img.shields.io/badge/hexo-5.0+-0e83c) ![license](https://img.shields.io/github/license/jerryc127/hexo-theme-butterfly?color=FF5531) +![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/theme-butterfly-readme.png) + 預覽: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [MYW](https://immyw.com/) 文檔: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/) @@ -79,7 +81,7 @@ theme: butterfly - [X] 多種評論系統(Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo) - [x] 支持雙評論部署 - [x] 多種在線聊天(Chatra/Tidio/Daovoice/Gitter/Crisp) -- [x] 多種分析系統(百度分析/谷歌分析/騰訊分析/CNZZ分析) +- [x] 多種分析系統 - [x] 谷歌廣告/手動廣告位置 - [x] 各種站長驗證(Google/Bing/Baidu/360/Yandex) - [x] 修改網站配色 @@ -96,6 +98,9 @@ theme: butterfly ## 截圖 +![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-1.jpg) +![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-2.jpg) +![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-3.jpg) +![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-4.jpg) ![](https://cdn.jsdelivr.net/gh/jerryc127/CDN/img/theme-butterfly-readme-homepage-1.png) - ![](https://cdn.jsdelivr.net/gh/jerryc127/CDN/img/theme-butterfly-readme-homepage-2.png) \ No newline at end of file diff --git a/_config.yml b/_config.yml index 16cf395e6..dbd13636c 100644 --- a/_config.yml +++ b/_config.yml @@ -4,7 +4,7 @@ # format: name: link || icon # sub-menu # name || icon: -# name || link || icon +# name: link || icon menu: # Home: / || fas fa-home @@ -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/404.pug b/layout/404.pug deleted file mode 100644 index e4b46e454..000000000 --- a/layout/404.pug +++ /dev/null @@ -1,28 +0,0 @@ -- var top_img = theme.error_404.background || theme.default_top_img -- var bg_img = `background-image: url('${url_for(top_img)}')` - -doctype html -html(lang=config.language data-theme=theme.display_mode) - head - include includes/head.pug - body - if theme.preloader - !=partial('includes/loading/loading', {}, {cache: true}) - - if theme.fireworks && theme.fireworks.enable - canvas.fireworks - - if theme.background - #web_bg - - #error-wrap - .error-content - .error-img(style=bg_img) - .error-info - h1.error_title= '404' - .error_subtitle= theme.error_404.subtitle - a.button--animated(href=config.root) - i.fas.fa-rocket - = _p('error404.back_button') - - include includes/additional-js.pug diff --git a/layout/includes/404.pug b/layout/includes/404.pug new file mode 100644 index 000000000..1b6b4e257 --- /dev/null +++ b/layout/includes/404.pug @@ -0,0 +1,17 @@ +- var top_img = theme.error_404.background || theme.default_top_img +- var bg_img = `background-image: url('${url_for(top_img)}')` + +#body-wrap.error + div(style='display: none') + include ./header/index.pug + + #error-wrap + .error-content + .error-img(style=bg_img) + .error-info + h1.error_title= '404' + .error_subtitle= theme.error_404.subtitle + a.button--animated(href=config.root) + i.fas.fa-rocket + = _p('error404.back_button') + diff --git a/layout/includes/head/config_site.pug b/layout/includes/head/config_site.pug index 1b951be6d..2dbd4633f 100644 --- a/layout/includes/head/config_site.pug +++ b/layout/includes/head/config_site.pug @@ -8,12 +8,12 @@ var showToc = is_post() && theme.aside.enable && pageToc && (toc(page.content) !== '' || page.encrypt == true ) - -script#config-diff - . - var GLOBAL_CONFIG_SITE = { - isPost: !{is_post()}, - isHome: !{is_home()}, - isHighlightShrink: !{isHighlightShrink}, - isToc: !{showToc}, - postUpdate: '!{full_date(page.updated)}' - } +script#config-diff. + var GLOBAL_CONFIG_SITE = { + title: '!{pageTitle}', + isPost: !{is_post()}, + isHome: !{is_home()}, + isHighlightShrink: !{isHighlightShrink}, + isToc: !{showToc}, + postUpdate: '!{full_date(page.updated)}' + } diff --git a/layout/includes/head/site_verification.pug b/layout/includes/head/site_verification.pug index cae574289..894764492 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/layout.pug b/layout/includes/layout.pug index 6d2cc2cdd..5245cced5 100644 --- a/layout/includes/layout.pug +++ b/layout/includes/layout.pug @@ -15,28 +15,32 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside !=partial('includes/sidebar', {}, {cache: true}) - #body-wrap(class=pageType) - include ./header/index.pug + if page.type !== '404' + #body-wrap(class=pageType) + include ./header/index.pug - main#content-inner.layout(class=hideAside) - if body - div!= body - else - block content - if theme.aside.enable && page.aside !== false - include widget/index.pug - - - var footerBg = theme.footer_bg - if (footerBg) - if (footerBg === true) - - var footer_bg = bg_img + main#content-inner.layout(class=hideAside) + if body + div!= body + else + block content + if theme.aside.enable && page.aside !== false + include widget/index.pug + + - var footerBg = theme.footer_bg + if (footerBg) + if (footerBg === true) + - var footer_bg = bg_img + else + - var footer_bg = theme.footer_bg.indexOf('/') !== -1 ? `background-image: url('${url_for(footerBg)}')` : `background: ${footerBg}` else - - var footer_bg = theme.footer_bg.indexOf('/') !== -1 ? `background-image: url('${url_for(footerBg)}')` : `background: ${footerBg}` - else - - var footer_bg = '' + - var footer_bg = '' + + footer#footer(style=footer_bg) + !=partial('includes/footer', {}, {cache: true}) - footer#footer(style=footer_bg) - !=partial('includes/footer', {}, {cache: true}) + else + include ./404.pug include ./rightside.pug !=partial('includes/third-party/search/index', {}, {cache: true}) diff --git a/layout/includes/mixins/article-sort.pug b/layout/includes/mixins/article-sort.pug index c2f1b5e28..01e9ef222 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 4d8778af6..cdf62ee5d 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 456d3b727..f0b088c91 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 8bb76a955..c50b81af4 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 0d6a584e0..41bb3c999 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 639dd798d..88551d7d6 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/third-party/comments/disqusjs.pug b/layout/includes/third-party/comments/disqusjs.pug index d1310b9dd..e88849aee 100644 --- a/layout/includes/third-party/comments/disqusjs.pug +++ b/layout/includes/third-party/comments/disqusjs.pug @@ -57,3 +57,4 @@ if is_post() && !theme.comments.lazyload && theme.comments.count && theme.commen } else { DISQUSWIDGETS.getCount({reset: true}); } + diff --git a/layout/includes/third-party/newest-comments/github-issues.pug b/layout/includes/third-party/newest-comments/github-issues.pug index bfc4341b6..4b3930804 100644 --- a/layout/includes/third-party/newest-comments/github-issues.pug +++ b/layout/includes/third-party/newest-comments/github-issues.pug @@ -102,4 +102,8 @@ script. newestCommentInit() document.addEventListener('pjax:complete', newestCommentInit) - }) \ No newline at end of file + }) + + + + diff --git a/layout/includes/third-party/pjax.pug b/layout/includes/third-party/pjax.pug index 853c6279a..024605165 100644 --- a/layout/includes/third-party/pjax.pug +++ b/layout/includes/third-party/pjax.pug @@ -26,6 +26,29 @@ script. scrollRestoration: false }) + document.addEventListener('pjax:send', function () { + + // removeEventListener toc scroll + window.removeEventListener('scroll', window.tocScrollFn) + + typeof preloader === 'object' && preloader.initLoading() + + if (window.aplayers) { + for (let i = 0; i < window.aplayers.length; i++) { + if (!window.aplayers[i].options.fixed) { + window.aplayers[i].destroy() + } + } + } + + typeof typed === 'object' && typed.destroy() + + //reset readmode + const $bodyClassList = document.body.classList + $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode') + + }) + document.addEventListener('pjax:complete', function () { window.refreshFn() @@ -61,26 +84,6 @@ script. typeof preloader === 'object' && preloader.endLoading() }) - - document.addEventListener('pjax:send', function () { - typeof preloader === 'object' && preloader.initLoading() - - if (window.aplayers) { - for (let i = 0; i < window.aplayers.length; i++) { - if (!window.aplayers[i].options.fixed) { - window.aplayers[i].destroy() - } - } - } - - typeof typed === 'object' && typed.destroy() - - //reset readmode - const $bodyClassList = document.body.classList - $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode') - - }) - document.addEventListener('pjax:error', (e) => { if (e.request.status === 404) { pjax.loadUrl('/404.html') diff --git a/layout/includes/widget/card_author.pug b/layout/includes/widget/card_author.pug index b694bd806..547fec869 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 b20747567..60a0e0708 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 1b51e2edc..e61a07713 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "3.7.1", + "version": "3.7.5", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/scripts/events/404.js b/scripts/events/404.js index c37daae40..02491ce7c 100644 --- a/scripts/events/404.js +++ b/scripts/events/404.js @@ -9,7 +9,10 @@ hexo.extend.generator.register('404', function (locals) { if (!hexo.theme.config.error_404.enable) return return { path: '404.html', - data: locals.posts, - layout: ['404'] + layout: ['page'], + data: { + type: '404', + top_img: false + } } }) diff --git a/scripts/events/init.js b/scripts/events/init.js index c198e9e80..76f78ef5f 100644 --- a/scripts/events/init.js +++ b/scripts/events/init.js @@ -2,7 +2,7 @@ const logger = require('hexo-log')() hexo.extend.filter.register('before_generate', () => { // Get first two digits of the Hexo version number - var hexoVer = hexo.version.replace(/(^.*\..*)\..*/, '$1') + const hexoVer = hexo.version.replace(/(^.*\..*)\..*/, '$1') if (hexoVer < 5) { logger.error('Please update Hexo to V5.0.0 or higher!') diff --git a/scripts/filters/post_lazyload.js b/scripts/filters/post_lazyload.js index c27963324..0b21de977 100644 --- a/scripts/filters/post_lazyload.js +++ b/scripts/filters/post_lazyload.js @@ -8,9 +8,22 @@ const urlFor = require('hexo-util').url_for.bind(hexo) +function lazyload (htmlContent) { + const bg = hexo.theme.config.lazyload.placeholder ? urlFor(hexo.theme.config.lazyload.placeholder) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=' + return htmlContent.replace(/( { - 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(/(' result += - 'cover' if (dateType === 'created') { diff --git a/scripts/tag/button.js b/scripts/tag/button.js index bb5a18a5d..791a8e335 100644 --- a/scripts/tag/button.js +++ b/scripts/tag/button.js @@ -22,7 +22,7 @@ function btn (args) { option = option.trim() return `${icon.length > 0 ? `` : ''}${text}` + title="${text}">${icon.length ? `` : ''}${text.length ? `${text}` : ''}` } hexo.extend.tag.register('btn', btn, { ends: false }) diff --git a/scripts/tag/label.js b/scripts/tag/label.js new file mode 100644 index 000000000..877c9097a --- /dev/null +++ b/scripts/tag/label.js @@ -0,0 +1,16 @@ +/** + * Butterfly + * label + * {% label text color %} + */ + +'use strict' + +function addLabel (args, content) { + const text = args[0] + const className = args[1] || 'default' + + return `${text} ` +} + +hexo.extend.tag.register('label', addLabel, { ends: false }) diff --git a/source/css/_global/index.styl b/source/css/_global/index.styl index 71fc5f11b..9563f7e43 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 da9b673e2..d287bfcb4 100644 --- a/source/css/_mode/darkmode.styl +++ b/source/css/_mode/darkmode.styl @@ -91,14 +91,20 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' .hide-button, .btn-beautify, .mermaid, + .hl-label, .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/css/_mode/readmode.styl b/source/css/_mode/readmode.styl index 0ef3b3648..aa1620720 100644 --- a/source/css/_mode/readmode.styl +++ b/source/css/_mode/readmode.styl @@ -173,24 +173,15 @@ if hexo-config('readmode') border: 1px solid var(--gray) !important .hide-button, - .btn-beautify + .btn-beautify, + .hl-label + border: 1px solid var(--gray) !important background: var(--readmode-light-color) !important color: var(--font-color) !important - .btn-beautify - border: 1px solid var(--gray) !important - .button--animated:before background: var(--readmode-light-color) !important - .hide-inline, - .hide-block - & >.hide-button - border: 1px solid var(--gray) - - & > .button--animated:before - background: var(--readmode-light-color) - .note border: 2px solid var(--gray) border-left-color: var(--gray) !important diff --git a/source/css/_tags/button.styl b/source/css/_tags/button.styl index 79cceed0c..7dcf0a71f 100644 --- a/source/css/_tags/button.styl +++ b/source/css/_tags/button.styl @@ -11,6 +11,9 @@ color: $btn-color line-height: 2 + i + span + margin-left: .3rem + &:not(.block) + .btn-beautify:not(.block) margin: 0 .2rem 1rem diff --git a/source/css/_tags/label.styl b/source/css/_tags/label.styl new file mode 100644 index 000000000..56261f146 --- /dev/null +++ b/source/css/_tags/label.styl @@ -0,0 +1,11 @@ +.hl-label + padding: 2px 4px + border-radius: 3px + color: $btn-color + + &.default + background-color: $btn-default-color + + for $type in $tagsP-types + &.{$type} + background-color: lookup('$tagsP-' + $type + '-color') diff --git a/source/img/loading.gif b/source/img/loading.gif deleted file mode 100644 index 46df25ad4..000000000 Binary files a/source/img/loading.gif and /dev/null differ diff --git a/source/js/main.js b/source/js/main.js index 9658c73c1..2d73c602e 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -388,11 +388,14 @@ document.addEventListener('DOMContentLoaded', function () { const $article = document.getElementById('article-container') // main of scroll - window.addEventListener('scroll', btf.throttle(function (e) { - const currentTop = window.scrollY || document.documentElement.scrollTop - scrollPercent(currentTop) - findHeadPosition(currentTop) - }, 100)) + window.tocScrollFn = function () { + return btf.throttle(function () { + const currentTop = window.scrollY || document.documentElement.scrollTop + scrollPercent(currentTop) + findHeadPosition(currentTop) + }, 100)() + } + window.addEventListener('scroll', tocScrollFn) const scrollPercent = function (currentTop) { const docHeight = $article.clientHeight @@ -410,7 +413,11 @@ document.addEventListener('DOMContentLoaded', function () { const updateAnchor = function (anchor) { if (window.history.replaceState && anchor !== window.location.hash) { if (!anchor) anchor = location.pathname - window.history.replaceState({}, '', anchor) + const title = GLOBAL_CONFIG_SITE.title + window.history.replaceState({ + url: location.href, + title: title + }, title, anchor) } }