From 484f036adb2e84f9dcb8fbe15df6218e1712910b Mon Sep 17 00:00:00 2001 From: Jerry Date: Wed, 1 Sep 2021 16:10:39 +0800 Subject: [PATCH] =?UTF-8?q?breaking=20changes:=20=E5=88=AA=E9=99=A4=20hide?= =?UTF-8?q?=5Fsidebar=5Fmenu=5Fchild=20=E9=85=8D=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E6=94=B9=E7=82=BA=E7=9B=B4=E6=8E=A5=E5=9C=A8=20menu=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=20close=20#640=20feat:=20sidebar=20menu=20?= =?UTF-8?q?=E9=BB=9E=E6=93=8A=E5=B1=95=E9=96=8B=E4=B8=8D=E5=86=8D=E9=99=90?= =?UTF-8?q?=E5=88=B6=E5=8F=AA=E8=83=BD=E9=BB=9E=E6=93=8A=E6=8C=89=E9=88=95?= =?UTF-8?q?=20#640=20feat:=20TWIKOO=20=E8=A9=95=E8=AB=96=E5=9C=96=E7=89=87?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20lightbox=20feat:=20=E5=8D=87=E7=B4=9A=20fa?= =?UTF-8?q?cebook=20comment=20js=20=E5=88=B0=20v11=20fix:=20=E4=BF=AE?= =?UTF-8?q?=E5=BE=A9=E5=8F=AF=E8=83=BD=E5=B0=8E=E8=87=B4=E7=9B=B8=E9=97=9C?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E9=8F=88=E6=8E=A5=E5=87=BA=E9=8C=AF=E7=9A=84?= =?UTF-8?q?bug=20#549=20improvement:=20=E8=AA=BF=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A2=BC=E6=A1=86=20ocean=20theme=20=E4=B8=8B=E6=BB=BE?= =?UTF-8?q?=E5=8B=95=E6=A2=9D=E9=A1=8F=E8=89=B2=20close=20#651=20improveme?= =?UTF-8?q?nt:=20=E7=95=B6=E5=9C=96=E7=89=87=E6=B2=92=E6=9C=89=20figcaptio?= =?UTF-8?q?n=20=E6=99=82=EF=BC=8C=E4=B8=8D=E6=9C=83=E6=B7=BB=E5=8A=A0=20fi?= =?UTF-8?q?gcaption=20=E4=BB=A3=E7=A2=BC=20improvement:=20=E4=BB=A3?= =?UTF-8?q?=E7=A2=BC=E5=84=AA=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 9 +- layout/includes/additional-js.pug | 31 ++-- layout/includes/head.pug | 4 +- layout/includes/head/config.pug | 4 - layout/includes/header/menu_item.pug | 29 ++-- .../comments/facebook_comments.pug | 2 +- .../includes/third-party/comments/twikoo.pug | 5 +- .../third-party/comments/utterances.pug | 4 +- package.json | 2 +- scripts/helpers/related_post.js | 34 +---- source/css/_highlight/highlight.styl | 3 +- source/css/_highlight/theme.styl | 2 +- source/css/_layout/head.styl | 6 +- source/css/_layout/sidebar.styl | 24 +-- source/js/main.js | 142 ++++++------------ source/js/utils.js | 29 +++- 16 files changed, 141 insertions(+), 189 deletions(-) diff --git a/_config.yml b/_config.yml index ae2a6f2..f8ae95f 100644 --- a/_config.yml +++ b/_config.yml @@ -1,11 +1,7 @@ # Main menu navigation (導航目錄) +# see https://butterfly.js.org/posts/4aa8abbe/#導航菜單 # -------------------------------------- -# format: name: link || icon -# sub-menu -# name || icon: -# name: link || icon - menu: # Home: / || fas fa-home # Archives: /archives/ || fas fa-archive @@ -17,9 +13,6 @@ menu: # Link: /link/ || fas fa-link # About: /about/ || fas fa-heart -# Hide the child menu items in mobile sidebar -hide_sidebar_menu_child: false - # Code Blocks (代碼相關) # -------------------------------------- diff --git a/layout/includes/additional-js.pug b/layout/includes/additional-js.pug index d125cd7..56d0f29 100644 --- a/layout/includes/additional-js.pug +++ b/layout/includes/additional-js.pug @@ -7,9 +7,11 @@ div if theme.medium_zoom script(src=url_for(theme.CDN.medium_zoom)) + else if theme.fancybox + script(src=url_for(theme.CDN.fancybox)) if theme.instantpage - script(src=url_for(theme.CDN.instantpage) type="module") + script(src=url_for(theme.CDN.instantpage), type='module') if theme.lazyload.enable script(src=url_for(theme.CDN.lazyload)) @@ -18,21 +20,22 @@ div script(src=url_for(theme.CDN.snackbar)) if theme.pangu.enable - !=partial('includes/third-party/pangu.pug', {}, {cache: true}) + != partial("includes/third-party/pangu.pug", {}, { cache: true }) //- search if theme.algolia_search.enable + script(src=url_for(theme.CDN.algolia_search)) script(src=url_for(theme.CDN.algolia_js)) else if theme.local_search.enable script(src=url_for(theme.CDN.local_search)) if theme.preloader - !=partial('includes/loading/loading-js', {}, {cache: true}) + != partial("includes/loading/loading-js", {}, { cache: true }) .js-pjax if needLoadCountJs - !=partial('includes/third-party/card-post-count/index', {}, {cache: true}) - + != partial("includes/third-party/card-post-count/index", {}, { cache: true }) + if loadSubJs include ./third-party/subtitle.pug @@ -41,20 +44,20 @@ div if commentsJsLoad include ./third-party/comments/js.pug - !=partial('includes/third-party/prismjs', {}, {cache: true}) + != partial("includes/third-party/prismjs", {}, { cache: true }) if theme.aside.enable && theme.newest_comments.enable if theme.pjax.enable - !=partial('includes/third-party/newest-comments/index', {}, {cache: true}) + != partial("includes/third-party/newest-comments/index", {}, { cache: true }) else if (!is_post() && page.aside !== false) - !=partial('includes/third-party/newest-comments/index', {}, {cache: true}) + != partial("includes/third-party/newest-comments/index", {}, { cache: true }) - !=fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)}) + != fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)}) - !=partial('includes/third-party/effect', {}, {cache: true}) + != partial("includes/third-party/effect", {}, { cache: true }) + + != partial("includes/third-party/chat/index", {}, { cache: true }) - !=partial('includes/third-party/chat/index', {}, {cache: true}) - if theme.aplayerInject && theme.aplayerInject.enable if theme.pjax.enable || theme.aplayerInject.per_page include ./third-party/aplayer.pug @@ -62,7 +65,7 @@ div include ./third-party/aplayer.pug if theme.pjax.enable - !=partial('includes/third-party/pjax', {}, {cache: true}) - + != partial("includes/third-party/pjax", {}, { cache: true }) + if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv script(async data-pjax src=url_for(theme.CDN.busuanzi)) diff --git a/layout/includes/head.pug b/layout/includes/head.pug index 3c1c96d..cefb644 100644 --- a/layout/includes/head.pug +++ b/layout/includes/head.pug @@ -54,7 +54,9 @@ if (theme.snackbar && theme.snackbar.enable) if theme.algolia_search.enable link(rel='stylesheet' href=url_for(theme.CDN.algolia_search_css) media="print" onload="this.media='all'") - script(src=url_for(theme.CDN.algolia_search) defer) + +if theme.fancybox + link(rel='stylesheet' href=url_for(theme.CDN.fancybox_css) media="print" onload="this.media='all'") //- google_adsense !=partial('includes/head/google_adsense', {}, {cache: true}) diff --git a/layout/includes/head/config.pug b/layout/includes/head/config.pug index 9dd4f3b..f669dbe 100644 --- a/layout/includes/head/config.pug +++ b/layout/includes/head/config.pug @@ -116,10 +116,6 @@ script. justifiedGallery: { js: '!{url_for(theme.CDN.justifiedGallery_js)}', css: '!{url_for(theme.CDN.justifiedGallery_css)}' - }, - fancybox: { - js: '!{url_for(theme.CDN.fancybox)}', - css: '!{url_for(theme.CDN.fancybox_css)}' } }, isPhotoFigcaption: !{theme.photofigcaption}, diff --git a/layout/includes/header/menu_item.pug b/layout/includes/header/menu_item.pug index 5a63994..d172db7 100644 --- a/layout/includes/header/menu_item.pug +++ b/layout/includes/header/menu_item.pug @@ -1,26 +1,27 @@ if theme.menu - //- for mobile sidebar - - let sidebarChildHide = theme.hide_sidebar_menu_child ? 'hide' : '' - .menus_items each value, label in theme.menu if typeof value !== 'object' .menus_item - a.site-page(href=url_for(trim(value.split('||')[0]))) - if value.split('||')[1] - i.fa-fw(class=trim(value.split('||')[1])) + - const valueArray = value.split('||') + a.site-page(href=url_for(trim(valueArray[0]))) + if valueArray[1] + i.fa-fw(class=trim(valueArray[1])) span=' '+label else .menus_item - a.site-page(href='javascript:void(0);') - if label.split('||')[1] - i.fa-fw(class=trim(label.split('||')[1])) - span=' '+ trim(label.split('||')[0]) - i.fas.fa-chevron-down.expand(class=sidebarChildHide) + - const labelArray = label.split('||') + - const hideClass = labelArray[2] && trim(labelArray[2]) === 'hide' ? 'hide' : '' + a.site-page.group(class=`${hideClass}` href='javascript:void(0);') + if labelArray[1] + i.fa-fw(class=trim(labelArray[1])) + span=' '+ trim(labelArray[0]) + i.fas.fa-chevron-down ul.menus_item_child each val,lab in value + - const valArray = val.split('||') li - a.site-page.child(href=url_for(trim(val.split('||')[0]))) - if val.split('||')[1] - i.fa-fw(class=trim(val.split('||')[1])) + a.site-page.child(href=url_for(trim(valArray[0]))) + if valArray[1] + i.fa-fw(class=trim(valArray[1])) span=' '+ lab \ No newline at end of file diff --git a/layout/includes/third-party/comments/facebook_comments.pug b/layout/includes/third-party/comments/facebook_comments.pug index 03cf3cd..54807cc 100644 --- a/layout/includes/third-party/comments/facebook_comments.pug +++ b/layout/includes/third-party/comments/facebook_comments.pug @@ -7,7 +7,7 @@ script. if (typeof FB === 'object') FB.XFBML.parse() else { let ele = document.createElement('script') - ele.setAttribute('src','https://connect.facebook.net/!{theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v10.0') + ele.setAttribute('src','https://connect.facebook.net/!{theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v11.0') ele.setAttribute('async', 'true') ele.setAttribute('defer', 'true') ele.setAttribute('crossorigin', 'anonymous') diff --git a/layout/includes/third-party/comments/twikoo.pug b/layout/includes/third-party/comments/twikoo.pug index 8fcf32f..c191cec 100644 --- a/layout/includes/third-party/comments/twikoo.pug +++ b/layout/includes/third-party/comments/twikoo.pug @@ -5,7 +5,10 @@ script. twikoo.init(Object.assign({ el: '#twikoo-wrap', envId: '!{theme.twikoo.envId}', - region: '!{theme.twikoo.region}' + region: '!{theme.twikoo.region}', + onCommentLoaded: function () { + btf.loadLightbox(document.querySelectorAll('#twikoo .tk-content img:not(.vemoji)')) + } }, !{JSON.stringify(theme.twikoo.option)})) } diff --git a/layout/includes/third-party/comments/utterances.pug b/layout/includes/third-party/comments/utterances.pug index dbd422f..25cccf2 100644 --- a/layout/includes/third-party/comments/utterances.pug +++ b/layout/includes/third-party/comments/utterances.pug @@ -13,13 +13,13 @@ script. } function utterancesTheme () { - if (document.querySelector('.utterances-frame')) { + const iframe = document.querySelector('.utterances-frame') + if (iframe) { const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}' const message = { type: 'set-theme', theme: theme }; - const iframe = document.querySelector('.utterances-frame'); iframe.contentWindow.postMessage(message, 'https://utteranc.es'); } } diff --git a/package.json b/package.json index de4578d..b49ca22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "4.0.0-b4", + "version": "4.0.0-b5", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/scripts/helpers/related_post.js b/scripts/helpers/related_post.js index 1e7efd4..2f8371a 100644 --- a/scripts/helpers/related_post.js +++ b/scripts/helpers/related_post.js @@ -46,11 +46,7 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { if (relatedPosts.length > 0) { result += '