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 += '