diff --git a/README.md b/README.md index 8b7b6e3..284ff41 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ npm i hexo-theme-butterfly - [x] Share (AddThis/Sharejs/Addtoany) - [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk) - [x] Multiple Comment System Support -- [x] Online Chats (Chatra/Tidio/Daovoice/Gitter/Crisp/messenger) +- [x] Online Chats (Chatra/Tidio/Daovoice/Crisp/messenger) - [x] Web analytics - [x] Google AdSense - [x] Webmaster Verification diff --git a/README_CN.md b/README_CN.md index 1dcfc96..f67c2e3 100644 --- a/README_CN.md +++ b/README_CN.md @@ -81,7 +81,7 @@ theme: butterfly - [x] 多種分享系統(AddThis/Sharejs/Addtoany) - [X] 多種評論系統(Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk) - [x] 支持雙評論部署 -- [x] 多種在線聊天(Chatra/Tidio/Daovoice/Gitter/Crisp/messenger) +- [x] 多種在線聊天(Chatra/Tidio/Daovoice/Crisp/messenger) - [x] 多種分析系統 - [x] 谷歌廣告/手動廣告位置 - [x] 各種站長驗證(Google/Bing/Baidu/360/Yandex) diff --git a/_config.yml b/_config.yml index dea86a3..db17670 100644 --- a/_config.yml +++ b/_config.yml @@ -416,12 +416,6 @@ daovoice: enable: false app_id: -# gitter -# https://gitter.im/ -gitter: - enable: false - room: - # crisp # https://crisp.chat/en/ crisp: @@ -907,7 +901,7 @@ CDN: # when set it to local, you need to install hexo-butterfly-extjs third_party_provider: jsdelivr - # Add version number to CDN, true or false + # Add version number to url, true or false version: false # Custom format @@ -921,8 +915,8 @@ CDN: # translate: # local_search: # algolia_js: - # algolia_search_v4: - # instantsearch_v4: + # algolia_search: + # instantsearch: # docsearch_js: # docsearch_css: # pjax: @@ -948,8 +942,8 @@ CDN: # instantpage: # typed: # pangu: - # fancybox_css_v4: - # fancybox_v4: + # fancybox_css: + # fancybox: # medium_zoom: # snackbar_css: # snackbar: @@ -957,7 +951,7 @@ CDN: # fireworks: # click_heart: # ClickShowText: - # fontawesomeV6: + # fontawesome: # flickr_justified_gallery_js: # flickr_justified_gallery_css: # aplayer_css: diff --git a/layout/includes/additional-js.pug b/layout/includes/additional-js.pug index 09a7898..3cb29f4 100644 --- a/layout/includes/additional-js.pug +++ b/layout/includes/additional-js.pug @@ -8,7 +8,7 @@ div if theme.medium_zoom script(src=url_for(theme.asset.medium_zoom)) else if theme.fancybox - script(src=url_for(theme.asset.fancybox_v4)) + script(src=url_for(theme.asset.fancybox)) if theme.instantpage script(src=url_for(theme.asset.instantpage), type='module') diff --git a/layout/includes/head.pug b/layout/includes/head.pug index 0089ad2..5cb3c61 100644 --- a/layout/includes/head.pug +++ b/layout/includes/head.pug @@ -40,13 +40,13 @@ if (theme.pwa && theme.pwa.enable) //- main css link(rel='stylesheet', href=url_for(theme.asset.main_css)) -link(rel='stylesheet', href=url_for(theme.asset.fontawesomeV6) media="print" onload="this.media='all'") +link(rel='stylesheet', href=url_for(theme.asset.fontawesome) media="print" onload="this.media='all'") if (theme.snackbar && theme.snackbar.enable) link(rel='stylesheet', href=url_for(theme.asset.snackbar_css) media="print" onload="this.media='all'") if theme.fancybox - link(rel='stylesheet' href=url_for(theme.asset.fancybox_css_v4) media="print" onload="this.media='all'") + link(rel='stylesheet' href=url_for(theme.asset.fancybox_css) media="print" onload="this.media='all'") //- google_adsense !=partial('includes/head/google_adsense', {}, {cache: true}) diff --git a/layout/includes/loading/pace.pug b/layout/includes/loading/pace.pug index e6813ba..7abd617 100644 --- a/layout/includes/loading/pace.pug +++ b/layout/includes/loading/pace.pug @@ -1,2 +1,11 @@ +script. + window.paceOptions = { + restartOnPushState: false + } + + document.addEventListener('pjax:send', () => { + Pace.restart() + }) + link(rel="stylesheet", href=url_for(theme.preloader.pace_css_url || theme.asset.pace_default_css)) script(src=url_for(theme.asset.pace_js)) \ No newline at end of file diff --git a/layout/includes/third-party/card-post-count/fb.pug b/layout/includes/third-party/card-post-count/fb.pug index eee1974..75d6b4a 100644 --- a/layout/includes/third-party/card-post-count/fb.pug +++ b/layout/includes/third-party/card-post-count/fb.pug @@ -1,4 +1,4 @@ -- const fbSDKVer = 'v15.0' +- const fbSDKVer = 'v16.0' - const fbSDK = theme.messenger.enable ? `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk/xfbml.customerchat.js#xfbml=1&version=${fbSDKVer}` : `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk.js#xfbml=1&version=${fbSDKVer}` script. diff --git a/layout/includes/third-party/chat/gitter.pug b/layout/includes/third-party/chat/gitter.pug deleted file mode 100644 index 46f979a..0000000 --- a/layout/includes/third-party/chat/gitter.pug +++ /dev/null @@ -1,43 +0,0 @@ -if theme.chat_btn - script. - ((window.gitter = {}).chat = {}).options = { - disableDefaultChat: true, - }; - document.addEventListener('gitter-sidecar-ready', (e) => { - const GitterChat = e.detail.Chat - let chat - - function initGitter () { - chat = new GitterChat({ - room: '#{theme.gitter.room}', - activationElement: '#chat_btn' - }); - } - - initGitter() - - if (!{theme.pjax.enable}) { - document.addEventListener('pjax:complete', () => { - chat.destroy() - initGitter() - }) - } - - }) -else - script. - ((window.gitter = {}).chat = {}).options = { - room: '#{theme.gitter.room}', - }; - - if (!{theme.chat_hide_show}) { - function chatBtnHide () { - document.getElementsByClassName('gitter-open-chat-button')[0].style.display= 'none' - } - - function chatBtnShow () { - document.getElementsByClassName('gitter-open-chat-button')[0].style.display= 'block' - } - } - -script(src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer) diff --git a/layout/includes/third-party/chat/index.pug b/layout/includes/third-party/chat/index.pug index dc6d0f8..4b6bda6 100644 --- a/layout/includes/third-party/chat/index.pug +++ b/layout/includes/third-party/chat/index.pug @@ -4,8 +4,6 @@ else if theme.tidio && theme.tidio.enable include ./tidio.pug else if theme.daovoice && theme.daovoice.enable include ./daovoice.pug -else if theme.gitter && theme.gitter.enable - include ./gitter.pug else if theme.crisp && theme.crisp.enable include ./crisp.pug else if theme.messenger && theme.messenger.enable diff --git a/layout/includes/third-party/chat/messenger.pug b/layout/includes/third-party/chat/messenger.pug index e7798ee..e5c9d88 100644 --- a/layout/includes/third-party/chat/messenger.pug +++ b/layout/includes/third-party/chat/messenger.pug @@ -9,7 +9,7 @@ script. window.fbAsyncInit = function() { FB.init({ xfbml: true, - version: 'v15.0' + version: 'v16.0' }); }; diff --git a/layout/includes/third-party/comments/facebook_comments.pug b/layout/includes/third-party/comments/facebook_comments.pug index 5d4d399..7172687 100644 --- a/layout/includes/third-party/comments/facebook_comments.pug +++ b/layout/includes/third-party/comments/facebook_comments.pug @@ -1,4 +1,4 @@ -- const fbSDKVer = 'v15.0' +- const fbSDKVer = 'v16.0' - const fbSDK = theme.messenger.enable ? `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk/xfbml.customerchat.js#xfbml=1&version=${fbSDKVer}` : `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk.js#xfbml=1&version=${fbSDKVer}` script. diff --git a/layout/includes/third-party/search/algolia.pug b/layout/includes/third-party/search/algolia.pug index bf5d019..b1f3c3d 100644 --- a/layout/includes/third-party/search/algolia.pug +++ b/layout/includes/third-party/search/algolia.pug @@ -17,6 +17,6 @@ #search-mask - script(src=url_for(theme.asset.algolia_search_v4)) - script(src=url_for(theme.asset.instantsearch_v4)) + script(src=url_for(theme.asset.algolia_search)) + script(src=url_for(theme.asset.instantsearch)) script(src=url_for(theme.asset.algolia_js)) \ No newline at end of file diff --git a/package.json b/package.json index f35e719..ca6f00d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "4.7.0", + "version": "4.8.0-b1", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/plugins.yml b/plugins.yml index 70d5687..b672299 100644 --- a/plugins.yml +++ b/plugins.yml @@ -1,11 +1,11 @@ -algolia_search_v4: +algolia_search: name: algoliasearch file: dist/algoliasearch-lite.umd.js version: 4.14.3 -instantsearch_v4: +instantsearch: name: instantsearch.js file: dist/instantsearch.production.min.js - version: 4.51.0 + version: 4.51.1 pjax: name: pjax file: pjax.min.js @@ -118,15 +118,15 @@ pangu: name: pangu file: dist/browser/pangu.min.js version: 4.0.7 -fancybox_css_v4: +fancybox_css: name: '@fancyapps/ui' - file: dist/fancybox.css - version: 4.0.31 + file: dist/fancybox/fancybox.css + version: 5.0.3 other_name: fancyapps-ui -fancybox_v4: +fancybox: name: '@fancyapps/ui' - file: dist/fancybox.umd.js - version: 4.0.31 + file: dist/fancybox/fancybox.umd.js + version: 5.0.3 other_name: fancyapps-ui medium_zoom: name: medium-zoom @@ -140,7 +140,7 @@ snackbar: name: node-snackbar file: dist/snackbar.min.js version: 0.1.16 -fontawesomeV6: +fontawesome: name: '@fortawesome/fontawesome-free' file: css/all.min.css other_name: font-awesome diff --git a/scripts/events/cdn.js b/scripts/events/cdn.js index 9c1b2c1..708420c 100644 --- a/scripts/events/cdn.js +++ b/scripts/events/cdn.js @@ -41,7 +41,7 @@ hexo.extend.filter.register('before_generate', () => { } } - const minFile = (file) => { + const minFile = file => { return file.replace(/(? '.min' + ext) } @@ -54,7 +54,7 @@ hexo.extend.filter.register('before_generate', () => { const cdnjs_file = file.replace(/^[lib|dist]*\/|browser\//g, '') const min_cdnjs_file = minFile(cdnjs_file) if (cond === 'internal') file = `source/${file}` - const verType = CDN.version ? `@${version}` : '' + const verType = CDN.version ? (type === 'local' ? `?v=${version}` : `@${version}`) : '' const value = { version, @@ -67,7 +67,7 @@ hexo.extend.filter.register('before_generate', () => { } const cdnSource = { - local: cond === 'internal' ? cdnjs_file : `/pluginsSrc/${name}/${file}`, + local: cond === 'internal' ? `${cdnjs_file + verType}` : `/pluginsSrc/${name}/${file + verType}`, jsdelivr: `https://cdn.jsdelivr.net/npm/${name}${verType}/${min_file}`, unpkg: `https://unpkg.com/${name}${verType}/${file}`, cdnjs: `https://cdnjs.cloudflare.com/ajax/libs/${cdnjs_name}/${version}/${min_cdnjs_file}`, @@ -77,7 +77,7 @@ hexo.extend.filter.register('before_generate', () => { data[key] = cdnSource[type] }) - if (cond === 'internal') data.main_css = 'css/index.css' + if (cond === 'internal') data.main_css = 'css/index.css' + (CDN.version ? `?v=${version}` : '') return data } @@ -90,6 +90,9 @@ hexo.extend.filter.register('before_generate', () => { return obj } - themeConfig.asset = Object.assign(createCDNLink(internalSrc, CDN.internal_provider, 'internal'), - createCDNLink(thirdPartySrc, CDN.third_party_provider), deleteNullValue(CDN.option)) + themeConfig.asset = Object.assign( + createCDNLink(internalSrc, CDN.internal_provider, 'internal'), + createCDNLink(thirdPartySrc, CDN.third_party_provider), + deleteNullValue(CDN.option) + ) }) diff --git a/scripts/filters/random_cover.js b/scripts/filters/random_cover.js index ffb61e4..4ecedce 100644 --- a/scripts/filters/random_cover.js +++ b/scripts/filters/random_cover.js @@ -6,7 +6,7 @@ 'use strict' hexo.extend.filter.register('before_post_render', function (data) { - const imgTestReg = /\.(png|jpe?g|gif|svg|webp)(\?.*)?$/ + const imgTestReg = /\.(png|jpe?g|gif|svg|webp)(\?.*)?$/i let randomCover let coverVal = data.cover diff --git a/scripts/helpers/page.js b/scripts/helpers/page.js index eaccb0f..22622c3 100644 --- a/scripts/helpers/page.js +++ b/scripts/helpers/page.js @@ -94,7 +94,7 @@ hexo.extend.helper.register('findArchivesTitle', function (page, menu, date) { }) hexo.extend.helper.register('isImgOrUrl', function (path) { - const imgTestReg = /\.(png|jpe?g|gif|svg|webp)(\?.*)?$/ + const imgTestReg = /\.(png|jpe?g|gif|svg|webp)(\?.*)?$/i if (path.indexOf('//') !== -1 || imgTestReg.test(path)) { return true } diff --git a/scripts/tag/gallery.js b/scripts/tag/gallery.js index adf46f3..632c514 100644 --- a/scripts/tag/gallery.js +++ b/scripts/tag/gallery.js @@ -15,18 +15,10 @@ function gallery (args, content) { args = args.join(' ').split(',') let rowHeight, limit, lazyload, type, dataStr - // url,[link],[lazyload],[rowHeight],[limit] if (args[0] === 'url') { - dataStr = args[1] - lazyload = args[2] === 'true' - rowHeight = args[3] || 220 - limit = args[4] || 10 - type = ' url' + [type, dataStr, lazyload, rowHeight = 220, limit = 10] = args // url,[link],[lazyload],[rowHeight],[limit] } else { - rowHeight = args[1] || 220 - limit = args[2] || 10 - lazyload = args[0] === 'true' - type = ' data' + [lazyload, rowHeight = 220, limit = 10] = args // [lazyload],[rowHeight],[limit] const regex = /!\[(.*?)\]\(([^\s]*)\s*(?:["'](.*?)["']?)?\s*\)/g let m const arr = [] @@ -44,7 +36,8 @@ function gallery (args, content) { dataStr = JSON.stringify(arr) } - const lazyloadClass = lazyload ? 'lazyload' : '' + type = type ? ' url' : ' data' + const lazyloadClass = lazyload === 'true' ? 'lazyload' : '' return `