From 060defa47587bdcf481f702679f6f699f51e58ba Mon Sep 17 00:00:00 2001 From: pai233 Date: Wed, 4 May 2022 12:44:39 +0800 Subject: [PATCH 01/17] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0Remark42?= =?UTF-8?q?=E8=AF=84=E8=AE=BA=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 11 +++++- .../includes/third-party/comments/index.pug | 4 ++- layout/includes/third-party/comments/js.pug | 2 ++ .../third-party/comments/remark42.pug | 34 +++++++++++++++++++ 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 layout/includes/third-party/comments/remark42.pug diff --git a/_config.yml b/_config.yml index 299f671..c2b0c2a 100644 --- a/_config.yml +++ b/_config.yml @@ -259,7 +259,7 @@ addtoany: comments: # Up to two comments system, the first will be shown as default - # Choose: Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus + # Choose: Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42 use: # Valine,Disqus text: true # Display the comment name next to the button # lazyload: The comment system will be load when comment element enters the browser's viewport. @@ -354,6 +354,15 @@ giscus: dark: dark option: +# Remark42 +# https://remark42.com/docs/getting-started/installation/ +remark42: + host: # required + siteId: remark # Your Site ID + language: en # https://remark42.com/docs/configuration/frontend/#locales + showEmailSubscription: true + simpleView: false + # Chat Services # -------------------------------------- diff --git a/layout/includes/third-party/comments/index.pug b/layout/includes/third-party/comments/index.pug index 6c725d6..dc99719 100644 --- a/layout/includes/third-party/comments/index.pug +++ b/layout/includes/third-party/comments/index.pug @@ -34,9 +34,11 @@ hr when 'Waline' #waline-wrap when 'Giscus' - #giscus-wrap + #giscus-wrap when 'Facebook Comments' .fb-comments(data-colorscheme = theme.display_mode === 'dark' ? 'dark' : 'light' data-numposts= theme.facebook_comments.pageSize || 10 data-order-by= theme.facebook_comments.order_by || 'social' data-width="100%") + when 'Remark42' + #remark42 diff --git a/layout/includes/third-party/comments/js.pug b/layout/includes/third-party/comments/js.pug index 1acd8d3..ff6f07b 100644 --- a/layout/includes/third-party/comments/js.pug +++ b/layout/includes/third-party/comments/js.pug @@ -20,3 +20,5 @@ each name in theme.comments.use !=partial('includes/third-party/comments/giscus', {}, {cache: true}) when 'Facebook Comments' !=partial('includes/third-party/comments/facebook_comments', {}, {cache: true}) + when 'Remark42' + !=partial('includes/third-party/comments/remark42', {}, {cache: true}) diff --git a/layout/includes/third-party/comments/remark42.pug b/layout/includes/third-party/comments/remark42.pug new file mode 100644 index 0000000..d6bae0d --- /dev/null +++ b/layout/includes/third-party/comments/remark42.pug @@ -0,0 +1,34 @@ +- const { host, siteId, language } = theme.remark42 +script. + var remark_config = { + host: '!{host}', + site_id: '!{siteId}', + components: ['embed'], + locale: '!{language}', + show_email_subscription: #{theme.remark42.showEmailSubscription}, + simple_view: #{theme.remark42.simpleView} + } + +script. + function loadRemark42(){ + !(function (e, n) { + for (var o = 0; o < e.length; o++) { + var r = n.createElement('script'), + c = '.js', + d = n.head || n.body + 'noModule' in r ? ((r.type = 'module'), (c = '.mjs')) : (r.async = !0), + (r.defer = !0), + (r.src = remark_config.host + '/web/' + e[o] + c), + d.appendChild(r) + } + })(remark_config.components || ['embed'], document) + } + + if ('!{theme.comments.use[0]}' === 'Remark42' || !!{theme.comments.lazyload}) { + if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('remark42'), loadRemark42) + else loadRemark42() + } else { + function loadOtherComment () { + loadRemark42() + } + } \ No newline at end of file From 41ac7f170c59534f4ff1c0fef2da5dfa25a12d5c Mon Sep 17 00:00:00 2001 From: pai233 Date: Wed, 11 May 2022 09:26:19 +0800 Subject: [PATCH 02/17] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0Remark42?= =?UTF-8?q?=E8=AF=84=E8=AE=BA=E7=B3=BB=E7=BB=9F=E4=B8=BB=E9=A2=98=E8=89=B2?= =?UTF-8?q?=E9=80=82=E5=BA=94=20feat:=20=E5=A2=9E=E5=8A=A0Remark42?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E8=AF=84=E8=AE=BA=E7=B3=BB=E7=BB=9F=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=98=BE=E7=A4=BA=E8=AF=84=E8=AE=BA=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 1 + layout/includes/third-party/comments/remark42.pug | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/_config.yml b/_config.yml index c2b0c2a..81a3222 100644 --- a/_config.yml +++ b/_config.yml @@ -362,6 +362,7 @@ remark42: language: en # https://remark42.com/docs/configuration/frontend/#locales showEmailSubscription: true simpleView: false + maxShownComments: 15 # Chat Services # -------------------------------------- diff --git a/layout/includes/third-party/comments/remark42.pug b/layout/includes/third-party/comments/remark42.pug index d6bae0d..e2c8b8c 100644 --- a/layout/includes/third-party/comments/remark42.pug +++ b/layout/includes/third-party/comments/remark42.pug @@ -1,11 +1,13 @@ - const { host, siteId, language } = theme.remark42 script. + let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light' var remark_config = { host: '!{host}', site_id: '!{siteId}', components: ['embed'], locale: '!{language}', show_email_subscription: #{theme.remark42.showEmailSubscription}, + theme: nowTheme, simple_view: #{theme.remark42.simpleView} } @@ -24,6 +26,16 @@ script. })(remark_config.components || ['embed'], document) } + function changeRemark42Theme(){ + let theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark' + window.REMARK42.changeTheme(theme) + } + + let themeBtn = document.getElementById('darkmode') + themeBtn.addEventListener('click',()=>{ + changeRemark42Theme() + }) + if ('!{theme.comments.use[0]}' === 'Remark42' || !!{theme.comments.lazyload}) { if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('remark42'), loadRemark42) else loadRemark42() From 7187a178968b93ce8e707112388bc87c35032ea1 Mon Sep 17 00:00:00 2001 From: pai233 Date: Wed, 11 May 2022 09:31:51 +0800 Subject: [PATCH 03/17] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0Remark42?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/_config.yml b/_config.yml index 81a3222..9a785cc 100644 --- a/_config.yml +++ b/_config.yml @@ -357,12 +357,12 @@ giscus: # Remark42 # https://remark42.com/docs/getting-started/installation/ remark42: - host: # required - siteId: remark # Your Site ID + host: # Your Host URL/你的Remark42的部署地址 + siteId: remark # Your Site ID/你的站点ID language: en # https://remark42.com/docs/configuration/frontend/#locales - showEmailSubscription: true - simpleView: false - maxShownComments: 15 + showEmailSubscription: true # Show Email Subscription/是否显示邮件订阅 + simpleView: false # Turn On the Simple View Mode/简单模式 + maxShownComments: 15 # The Max Shown Comments When the System loaded/默认加载时评论的显示数量 # Chat Services # -------------------------------------- From f768d6fce0f2a40aa1d55130da9feef301f8d722 Mon Sep 17 00:00:00 2001 From: pai233 Date: Wed, 11 May 2022 09:35:39 +0800 Subject: [PATCH 04/17] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E7=A9=BA=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/includes/third-party/comments/index.pug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layout/includes/third-party/comments/index.pug b/layout/includes/third-party/comments/index.pug index dc99719..c65a37d 100644 --- a/layout/includes/third-party/comments/index.pug +++ b/layout/includes/third-party/comments/index.pug @@ -34,7 +34,7 @@ hr when 'Waline' #waline-wrap when 'Giscus' - #giscus-wrap + #giscus-wrap when 'Facebook Comments' .fb-comments(data-colorscheme = theme.display_mode === 'dark' ? 'dark' : 'light' data-numposts= theme.facebook_comments.pageSize || 10 From c68e872f0e5ab1d8f10f5d82af1c7ffcafa2412c Mon Sep 17 00:00:00 2001 From: pai233 Date: Wed, 11 May 2022 13:47:54 +0800 Subject: [PATCH 05/17] =?UTF-8?q?feat:=20=E5=B0=86Remark42=E7=9A=84?= =?UTF-8?q?=E5=8F=AF=E9=80=89=E9=85=8D=E7=BD=AE=E5=BD=92=E5=85=A5option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 4 +--- layout/includes/third-party/comments/remark42.pug | 9 +++------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/_config.yml b/_config.yml index 9a785cc..773c7fa 100644 --- a/_config.yml +++ b/_config.yml @@ -360,9 +360,7 @@ remark42: host: # Your Host URL/你的Remark42的部署地址 siteId: remark # Your Site ID/你的站点ID language: en # https://remark42.com/docs/configuration/frontend/#locales - showEmailSubscription: true # Show Email Subscription/是否显示邮件订阅 - simpleView: false # Turn On the Simple View Mode/简单模式 - maxShownComments: 15 # The Max Shown Comments When the System loaded/默认加载时评论的显示数量 + option: # Chat Services # -------------------------------------- diff --git a/layout/includes/third-party/comments/remark42.pug b/layout/includes/third-party/comments/remark42.pug index e2c8b8c..378ee55 100644 --- a/layout/includes/third-party/comments/remark42.pug +++ b/layout/includes/third-party/comments/remark42.pug @@ -1,15 +1,12 @@ -- const { host, siteId, language } = theme.remark42 +- const { host, siteId, language, option } = theme.remark42 script. let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light' - var remark_config = { + var remark_config = Object.assign({ host: '!{host}', site_id: '!{siteId}', components: ['embed'], locale: '!{language}', - show_email_subscription: #{theme.remark42.showEmailSubscription}, - theme: nowTheme, - simple_view: #{theme.remark42.simpleView} - } + },!{JSON.stringify(option)}) script. function loadRemark42(){ From 1f3f2f471bd5826a71025d8ea20fc31e51aab45a Mon Sep 17 00:00:00 2001 From: pai233 Date: Thu, 12 May 2022 08:39:56 +0800 Subject: [PATCH 06/17] =?UTF-8?q?feat:=20Remark42=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=98=BE=E7=A4=BA=E6=96=87=E7=AB=A0=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/includes/header/post-info.pug | 6 +++++- layout/includes/mixins/post-ui.pug | 4 ++++ .../third-party/card-post-count/index.pug | 4 +++- .../third-party/card-post-count/remark42.pug | 21 +++++++++++++++++++ .../third-party/comments/remark42.pug | 2 +- 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 layout/includes/third-party/card-post-count/remark42.pug diff --git a/layout/includes/header/post-info.pug b/layout/includes/header/post-info.pug index 3293697..6993123 100644 --- a/layout/includes/header/post-info.pug +++ b/layout/includes/header/post-info.pug @@ -116,4 +116,8 @@ when 'Facebook Comments' +countBlock a(href=url_for(page.path) + '#post-comment') - span.fb-comments-count(data-href=urlNoIndex()) \ No newline at end of file + span.fb-comments-count(data-href=urlNoIndex()) + when 'Remark42' + +countBlock + a(href=url_for(page.path) + '#post-comment') + span(class="remark42__counter" data-url=urlNoIndex()) \ No newline at end of file diff --git a/layout/includes/mixins/post-ui.pug b/layout/includes/mixins/post-ui.pug index d2cb014..d3bf406 100644 --- a/layout/includes/mixins/post-ui.pug +++ b/layout/includes/mixins/post-ui.pug @@ -88,6 +88,10 @@ mixin postUI(posts) +countBlockInIndex a(href=url_for(link) + '#post-comment') span.fb-comments-count(data-href=urlNoIndex(article.permalink)) + when 'Remark42' + +countBlockInIndex + a(href=url_for(link) + '#post-comment') + span(class="remark42__counter" data-url=urlNoIndex(article.permalink)) //- Display the article introduction on homepage case theme.index_post_content.method diff --git a/layout/includes/third-party/card-post-count/index.pug b/layout/includes/third-party/card-post-count/index.pug index 44839b3..195d9ec 100644 --- a/layout/includes/third-party/card-post-count/index.pug +++ b/layout/includes/third-party/card-post-count/index.pug @@ -9,4 +9,6 @@ case theme.comments.use[0] when 'Waline' include ./waline.pug when 'Facebook Comments' - include ./fb.pug \ No newline at end of file + include ./fb.pug + when 'Remark42' + include ./remark42.pug \ No newline at end of file diff --git a/layout/includes/third-party/card-post-count/remark42.pug b/layout/includes/third-party/card-post-count/remark42.pug new file mode 100644 index 0000000..7de001b --- /dev/null +++ b/layout/includes/third-party/card-post-count/remark42.pug @@ -0,0 +1,21 @@ +- const { host, siteId, language, option } = theme.remark42 + +script. + let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light' + var remark_config = Object.assign({ + host: '!{host}', + site_id: '!{siteId}', + components: ['counter'] + },!{JSON.stringify(option)}) + +script. + function loadRemark42(){ + !function(e,r){ + for(var o=r.head||r.body,n=0;n Date: Thu, 12 May 2022 20:56:46 +0800 Subject: [PATCH 07/17] Update index.pug --- layout/includes/third-party/card-post-count/index.pug | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layout/includes/third-party/card-post-count/index.pug b/layout/includes/third-party/card-post-count/index.pug index 195d9ec..0c12d82 100644 --- a/layout/includes/third-party/card-post-count/index.pug +++ b/layout/includes/third-party/card-post-count/index.pug @@ -10,5 +10,5 @@ case theme.comments.use[0] include ./waline.pug when 'Facebook Comments' include ./fb.pug - when 'Remark42' - include ./remark42.pug \ No newline at end of file + when 'Remark42' + include ./remark42.pug From cbf52c3053813ede7d63ce282eeab8efc74fe226 Mon Sep 17 00:00:00 2001 From: pai233 Date: Fri, 13 May 2022 10:22:16 +0800 Subject: [PATCH 08/17] =?UTF-8?q?feat:=20Remark42=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=9C=80=E6=96=B0=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../third-party/newest-comments/index.pug | 4 +- .../third-party/newest-comments/remark42.pug | 92 +++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 layout/includes/third-party/newest-comments/remark42.pug diff --git a/layout/includes/third-party/newest-comments/index.pug b/layout/includes/third-party/newest-comments/index.pug index 190e81a..826ccff 100644 --- a/layout/includes/third-party/newest-comments/index.pug +++ b/layout/includes/third-party/newest-comments/index.pug @@ -23,4 +23,6 @@ if use include ./github-issues.pug when 'Utterances' - userRepo = theme.utterances.repo - include ./github-issues.pug \ No newline at end of file + include ./github-issues.pug + when 'Remark42' + include ./remark42.pug \ No newline at end of file diff --git a/layout/includes/third-party/newest-comments/remark42.pug b/layout/includes/third-party/newest-comments/remark42.pug new file mode 100644 index 0000000..4b44095 --- /dev/null +++ b/layout/includes/third-party/newest-comments/remark42.pug @@ -0,0 +1,92 @@ +- const { host, siteId } = theme.remark42 +- const { limit } = theme.newest_comments + +script. + window.addEventListener('load', () => { + const api = ['!{host}','/api/v1/last/','!{limit}','?site=','!{siteId}'].join('') + + const changeContent = (content) => { + if (content === '') return content + + content = content.replace(/]+>/ig, '[!{_p("aside.card_newest_comments.image")}]') // replace image link + content = content.replace(/]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[!{_p("aside.card_newest_comments.link")}]') // replace url + content = content.replace(/
.*?<\/pre>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
+            content = content.replace(/<[^>]+>/g,"") // remove html tag
+
+            if (content.length > 150) {
+                content = content.substring(0,150) + '...'
+            }
+            return content
+        }
+
+        const getComment = () => {
+            try {
+                let request = new XMLHttpRequest()
+                request.open("GET",api)
+                request.send(null)
+                request.onload = () => {
+                    if (request.status == 200) {
+                        const commentsData = JSON.parse(request.responseText)
+                        const commentsArray = commentsData.map(k => {
+                            return {
+                                'content': changeContent(k.text), //Maybe we can use e.orig
+                                'avatar': k.user.picture,
+                                'nick': k.user.name,
+                                'url': k.locator.url,
+                                'date': new Date(k.time).toISOString()
+                            }
+                        })
+
+                        saveToLocal.set('remark42-newest-comments', JSON.stringify(commentsArray), !{theme.newest_comments.storage}/(60*24))
+                        generateHtml(commentsArray)
+                    } else {
+                        throw Error("Request to Remark42 Failed")
+                    }
+                }
+            } catch(e) {
+                const $dom = document.querySelector('#card-newest-comments .aside-list')
+                $dom.innerHTML= "!{_p('aside.card_newest_comments.error')}"
+            }
+        }
+
+        const generateHtml = array => {
+            let result = ''
+
+            if (array.length) {
+                for (let i = 0; i < array.length; i++) {
+                result += '
' + + if (!{theme.newest_comments.avatar}) { + const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}' + result += `${array[i].nick}` + } + + result += `
+ ${array[i].content} +
${array[i].nick} /
+
` + } + } else { + result += '!{_p("aside.card_newest_comments.zero")}' + } + + let $dom = document.querySelector('#card-newest-comments .aside-list') + $dom.innerHTML= result + window.lazyLoadInstance && window.lazyLoadInstance.update() + window.pjax && window.pjax.refresh($dom) + } + + const newestCommentInit = () => { + if (document.querySelector('#card-newest-comments .aside-list')) { + const data = saveToLocal.get('remark42-newest-comments') + if (data) { + generateHtml(JSON.parse(data)) + } else { + getComment() + } + } + } + + newestCommentInit() + document.addEventListener('pjax:complete', newestCommentInit) + }) \ No newline at end of file From 4df78b1966a5aca9c80656076e5981fbe883f39b Mon Sep 17 00:00:00 2001 From: Jerry Wong Date: Tue, 17 May 2022 16:03:25 +0800 Subject: [PATCH 09/17] fix pjax --- README.md | 2 +- README_CN.md | 2 +- _config.yml | 7 +- layout/includes/header/post-info.pug | 2 +- layout/includes/mixins/post-ui.pug | 2 +- .../third-party/card-post-count/index.pug | 2 +- .../third-party/card-post-count/remark42.pug | 27 ++-- .../includes/third-party/comments/index.pug | 2 +- layout/includes/third-party/comments/js.pug | 2 +- .../third-party/comments/remark42.pug | 94 ++++++----- .../third-party/newest-comments/remark42.pug | 148 ++++++++---------- 11 files changed, 149 insertions(+), 141 deletions(-) diff --git a/README.md b/README.md index a7018ad..2c7c7b2 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ npm i hexo-theme-butterfly - [x] Related articles - [x] Displays outdated notice for a post - [x] Share (AddThis/Sharejs/Addtoany) -- [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus) +- [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42) - [x] Multiple Comment System Support - [x] Online Chats (Chatra/Tidio/Daovoice/Gitter/Crisp) - [x] Web analytics diff --git a/README_CN.md b/README_CN.md index c19ef07..c98ef14 100644 --- a/README_CN.md +++ b/README_CN.md @@ -79,7 +79,7 @@ theme: butterfly - [x] 顯示相關文章 - [x] 過期文章提醒 - [x] 多種分享系統(AddThis/Sharejs/Addtoany) -- [X] 多種評論系統(Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus) +- [X] 多種評論系統(Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42) - [x] 支持雙評論部署 - [x] 多種在線聊天(Chatra/Tidio/Daovoice/Gitter/Crisp) - [x] 多種分析系統 diff --git a/_config.yml b/_config.yml index 773c7fa..4774408 100644 --- a/_config.yml +++ b/_config.yml @@ -355,11 +355,10 @@ giscus: option: # Remark42 -# https://remark42.com/docs/getting-started/installation/ +# https://remark42.com/docs/configuration/frontend/ remark42: - host: # Your Host URL/你的Remark42的部署地址 - siteId: remark # Your Site ID/你的站点ID - language: en # https://remark42.com/docs/configuration/frontend/#locales + host: # Your Host URL + siteId: # Your Site ID option: # Chat Services diff --git a/layout/includes/header/post-info.pug b/layout/includes/header/post-info.pug index 6993123..8cabfe7 100644 --- a/layout/includes/header/post-info.pug +++ b/layout/includes/header/post-info.pug @@ -120,4 +120,4 @@ when 'Remark42' +countBlock a(href=url_for(page.path) + '#post-comment') - span(class="remark42__counter" data-url=urlNoIndex()) \ No newline at end of file + span.remark42__counter(data-url=urlNoIndex()) \ No newline at end of file diff --git a/layout/includes/mixins/post-ui.pug b/layout/includes/mixins/post-ui.pug index d3bf406..9ef2e00 100644 --- a/layout/includes/mixins/post-ui.pug +++ b/layout/includes/mixins/post-ui.pug @@ -91,7 +91,7 @@ mixin postUI(posts) when 'Remark42' +countBlockInIndex a(href=url_for(link) + '#post-comment') - span(class="remark42__counter" data-url=urlNoIndex(article.permalink)) + span.remark42__counter(data-url=urlNoIndex(article.permalink)) //- Display the article introduction on homepage case theme.index_post_content.method diff --git a/layout/includes/third-party/card-post-count/index.pug b/layout/includes/third-party/card-post-count/index.pug index 0c12d82..0abc970 100644 --- a/layout/includes/third-party/card-post-count/index.pug +++ b/layout/includes/third-party/card-post-count/index.pug @@ -11,4 +11,4 @@ case theme.comments.use[0] when 'Facebook Comments' include ./fb.pug when 'Remark42' - include ./remark42.pug + include ./remark42.pug \ No newline at end of file diff --git a/layout/includes/third-party/card-post-count/remark42.pug b/layout/includes/third-party/card-post-count/remark42.pug index 7de001b..b67164f 100644 --- a/layout/includes/third-party/card-post-count/remark42.pug +++ b/layout/includes/third-party/card-post-count/remark42.pug @@ -1,21 +1,18 @@ -- const { host, siteId, language, option } = theme.remark42 +- const { host, siteId, option } = theme.remark42 script. - let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light' - var remark_config = Object.assign({ - host: '!{host}', - site_id: '!{siteId}', - components: ['counter'] + (()=>{ + window.remark_config = Object.assign({ + host: '!{host}', + site_id: '!{siteId}', },!{JSON.stringify(option)}) -script. - function loadRemark42(){ - !function(e,r){ - for(var o=r.head||r.body,n=0;n{ - changeRemark42Theme() - }) + function getCount () { + const ele = document.querySelector('.remark42__counter') + if (ele) { + const s = document.createElement('script') + s.src = remark_config.host + '/web/counter.js' + s.defer = true + document.head.appendChild(s) + } + } - if ('!{theme.comments.use[0]}' === 'Remark42' || !!{theme.comments.lazyload}) { - if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('remark42'), loadRemark42) - else loadRemark42() + function loadRemark42 () { + if (window.REMARK42) { + this.initRemark42() + getCount() } else { - function loadOtherComment () { - loadRemark42() - } - } \ No newline at end of file + addRemark42() + window.addEventListener('REMARK42::ready', () => { + this.initRemark42() + getCount() + }) + } + } + + document.getElementById('darkmode').addEventListener('click',()=>{ + if (!window.REMARK42) return + let theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark' + window.REMARK42.changeTheme(theme) + }) + + if ('!{theme.comments.use[0]}' === 'Remark42' || !!{theme.comments.lazyload}) { + if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('remark42'), loadRemark42) + else loadRemark42() + } else { + function loadOtherComment () { + loadRemark42() + } + } diff --git a/layout/includes/third-party/newest-comments/remark42.pug b/layout/includes/third-party/newest-comments/remark42.pug index 4b44095..d14adb9 100644 --- a/layout/includes/third-party/newest-comments/remark42.pug +++ b/layout/includes/third-party/newest-comments/remark42.pug @@ -1,92 +1,80 @@ - const { host, siteId } = theme.remark42 -- const { limit } = theme.newest_comments script. - window.addEventListener('load', () => { - const api = ['!{host}','/api/v1/last/','!{limit}','?site=','!{siteId}'].join('') + window.addEventListener('load', () => { + const changeContent = (content) => { + if (content === '') return content - const changeContent = (content) => { - if (content === '') return content + content = content.replace(/]+>/ig, '[!{_p("aside.card_newest_comments.image")}]') // replace image link + content = content.replace(/]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[!{_p("aside.card_newest_comments.link")}]') // replace url + content = content.replace(/
.*?<\/pre>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
+      content = content.replace(/<[^>]+>/g,"") // remove html tag
 
-            content = content.replace(/]+>/ig, '[!{_p("aside.card_newest_comments.image")}]') // replace image link
-            content = content.replace(/]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[!{_p("aside.card_newest_comments.link")}]') // replace url
-            content = content.replace(/
.*?<\/pre>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
-            content = content.replace(/<[^>]+>/g,"") // remove html tag
+      if (content.length > 150) {
+        content = content.substring(0,150) + '...'
+      }
+      return content
+    }
 
-            if (content.length > 150) {
-                content = content.substring(0,150) + '...'
-            }
-            return content
+    const generateHtml = array => {
+      let result = ''
+
+      if (array.length) {
+        for (let i = 0; i < array.length; i++) {
+          result += '
' + + if (!{theme.newest_comments.avatar}) { + const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}' + result += `${array[i].nick}` + } + + result += `
+ ${array[i].content} +
${array[i].nick} /
+
` } + } else { + result += '!{_p("aside.card_newest_comments.zero")}' + } - const getComment = () => { - try { - let request = new XMLHttpRequest() - request.open("GET",api) - request.send(null) - request.onload = () => { - if (request.status == 200) { - const commentsData = JSON.parse(request.responseText) - const commentsArray = commentsData.map(k => { - return { - 'content': changeContent(k.text), //Maybe we can use e.orig - 'avatar': k.user.picture, - 'nick': k.user.name, - 'url': k.locator.url, - 'date': new Date(k.time).toISOString() - } - }) + let $dom = document.querySelector('#card-newest-comments .aside-list') + $dom.innerHTML= result + window.lazyLoadInstance && window.lazyLoadInstance.update() + window.pjax && window.pjax.refresh($dom) + } - saveToLocal.set('remark42-newest-comments', JSON.stringify(commentsArray), !{theme.newest_comments.storage}/(60*24)) - generateHtml(commentsArray) - } else { - throw Error("Request to Remark42 Failed") - } - } - } catch(e) { - const $dom = document.querySelector('#card-newest-comments .aside-list') - $dom.innerHTML= "!{_p('aside.card_newest_comments.error')}" + const getComment = () => { + fetch('!{host}/api/v1/last/!{theme.newest_comments.limit}?site=!{siteId}') + .then(response => response.json()) + .then(data => { + const remark42 = data.map(function (e) { + return { + 'avatar': e.user.picture, + 'content': changeContent(e.text), + 'nick': e.user.name, + 'url': e.locator.url, + 'date': e.time, } + }) + saveToLocal.set('remark42-newest-comments', JSON.stringify(remark42), !{theme.newest_comments.storage}/(60*24)) + generateHtml(remark42) + }).catch(e => { + const $dom = document.querySelector('#card-newest-comments .aside-list') + $dom.innerHTML= "!{_p('aside.card_newest_comments.error')}" + }) + } + + const newestCommentInit = () => { + if (document.querySelector('#card-newest-comments .aside-list')) { + const data = saveToLocal.get('valine-newest-comments') + if (data) { + generateHtml(JSON.parse(data)) + } else { + getComment() } + } + } - const generateHtml = array => { - let result = '' - - if (array.length) { - for (let i = 0; i < array.length; i++) { - result += '
' - - if (!{theme.newest_comments.avatar}) { - const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}' - result += `${array[i].nick}` - } - - result += `
- ${array[i].content} -
${array[i].nick} /
-
` - } - } else { - result += '!{_p("aside.card_newest_comments.zero")}' - } - - let $dom = document.querySelector('#card-newest-comments .aside-list') - $dom.innerHTML= result - window.lazyLoadInstance && window.lazyLoadInstance.update() - window.pjax && window.pjax.refresh($dom) - } - - const newestCommentInit = () => { - if (document.querySelector('#card-newest-comments .aside-list')) { - const data = saveToLocal.get('remark42-newest-comments') - if (data) { - generateHtml(JSON.parse(data)) - } else { - getComment() - } - } - } - - newestCommentInit() - document.addEventListener('pjax:complete', newestCommentInit) - }) \ No newline at end of file + newestCommentInit() + document.addEventListener('pjax:complete', newestCommentInit) + }) From 9a86429484805d25fbe316efed10c8f532e83171 Mon Sep 17 00:00:00 2001 From: Jerry Wong Date: Thu, 19 May 2022 16:45:30 +0800 Subject: [PATCH 10/17] =?UTF-8?q?breaking=20changes:=20=E9=81=A9=E9=85=8D?= =?UTF-8?q?=20disqusjs=203.0=20fix:=20=E4=BF=AE=E5=BE=A9=E9=A6=96=E9=A0=81?= =?UTF-8?q?=E6=96=87=E7=AB=A0=20valine=20=E8=A9=95=E8=AB=96=E6=95=B8?= =?UTF-8?q?=E5=8F=AA=E9=A1=AF=E7=A4=BA=E7=AC=AC=E4=B8=80=E7=AF=87=E7=9A=84?= =?UTF-8?q?=20bug=20fix:=20=E4=BF=AE=E5=BE=A9=E5=AD=90=E7=9B=AE=E9=8C=84?= =?UTF-8?q?=E4=B8=8B=EF=BC=8C=E7=AC=AC=E4=B8=89=E6=96=B9=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=B3=87=E6=BA=90=E7=84=A1=E6=B3=95=E5=8A=A0?= =?UTF-8?q?=E8=BC=89=E7=9A=84=20bug=20closed=20#908=20fix:=20=E8=A9=95?= =?UTF-8?q?=E8=AB=96=E7=B3=BB=E7=B5=B1=E9=96=8B=E5=95=9F=E6=99=82=20busuan?= =?UTF-8?q?zi=20=E7=9A=84=20page=5Fpv=20=E4=B8=8D=E9=A1=AF=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=20bug=20closed=20#902=20fix:=20=E4=BF=AE=E5=BE=A9=20p?= =?UTF-8?q?jax=20=E4=B8=8B=EF=BC=8C=E4=BD=BF=E7=94=A8=20mermaid=20?= =?UTF-8?q?=E8=B7=B3=E8=BD=89=E6=9C=83=E9=87=8D=E6=96=B0=E5=8A=A0=E8=BC=89?= =?UTF-8?q?=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/includes/header/post-info.pug | 9 ++++++++- layout/includes/mixins/post-ui.pug | 9 ++++++--- .../third-party/card-post-count/twikoo.pug | 2 +- .../third-party/card-post-count/valine.pug | 1 + .../includes/third-party/comments/disqus.pug | 6 +++++- .../third-party/comments/disqusjs.pug | 19 ++++++++++++++----- .../includes/third-party/comments/index.pug | 2 +- .../includes/third-party/comments/twikoo.pug | 4 ++-- layout/includes/third-party/math/katex.pug | 4 ++-- layout/includes/third-party/math/mathjax.pug | 2 +- layout/includes/third-party/math/mermaid.pug | 2 +- .../newest-comments/twikoo-comment.pug | 2 +- layout/includes/third-party/pjax.pug | 3 ++- package.json | 2 +- scripts/events/config.js | 4 ++-- source/css/_mode/darkmode.styl | 4 +++- source/js/main.js | 1 - 17 files changed, 51 insertions(+), 25 deletions(-) diff --git a/layout/includes/header/post-info.pug b/layout/includes/header/post-info.pug index 3293697..206b993 100644 --- a/layout/includes/header/post-info.pug +++ b/layout/includes/header/post-info.pug @@ -76,6 +76,10 @@ if theme.twikoo.visitor +pvBlock('','','') span#twikoo_visitors + default + if theme.busuanzi.page_pv + +pvBlock('','post-meta-pv-cv','') + span#busuanzi_value_page_pv else if theme.busuanzi.page_pv +pvBlock('','post-meta-pv-cv','') span#busuanzi_value_page_pv @@ -93,10 +97,13 @@ case whichCount when 'Disqus' - when 'Disqusjs' +countBlock span.disqus-comment-count a(href=full_url_for(page.path) + '#disqus_thread') + when 'Disqusjs' + +countBlock + a(href=full_url_for(page.path) + '#disqusjs') + span.disqus-comment-count(data-disqus-url=full_url_for(page.path)) when 'Valine' +countBlock a(href=url_for(page.path) + '#post-comment' itemprop="discussionUrl") diff --git a/layout/includes/mixins/post-ui.pug b/layout/includes/mixins/post-ui.pug index d2cb014..8076409 100644 --- a/layout/includes/mixins/post-ui.pug +++ b/layout/includes/mixins/post-ui.pug @@ -70,13 +70,16 @@ mixin postUI(posts) if theme.comments.card_post_count case theme.comments.use[0] when 'Disqus' - when 'Disqusjs' +countBlockInIndex a(href=full_url_for(link) + '#disqus_thread') + when 'Disqusjs' + +countBlockInIndex + a(href=full_url_for(link) + '#disqusjs') + span.disqus-comment-count(data-disqus-url=full_url_for(link)) when 'Valine' +countBlockInIndex - a(href=url_for(link) + '#post-comment' itemprop="discussionUrl") - span.valine-comment-count(data-xid=url_for(link) itemprop="commentCount") + a(href=url_for(link) + '#post-comment') + span.valine-comment-count(data-xid=url_for(link)) when 'Waline' +countBlockInIndex a(href=url_for(link) + '#post-comment') diff --git a/layout/includes/third-party/card-post-count/twikoo.pug b/layout/includes/third-party/card-post-count/twikoo.pug index 68ab35b..314e4ac 100644 --- a/layout/includes/third-party/card-post-count/twikoo.pug +++ b/layout/includes/third-party/card-post-count/twikoo.pug @@ -28,7 +28,7 @@ script. if (typeof twikoo === 'object') { runTwikoo() } else { - getScript('!{theme.asset.twikoo}').then(runTwikoo) + getScript('!{url_for(theme.asset.twikoo)}').then(runTwikoo) } } diff --git a/layout/includes/third-party/card-post-count/valine.pug b/layout/includes/third-party/card-post-count/valine.pug index 2d422fd..dfe9b6d 100644 --- a/layout/includes/third-party/card-post-count/valine.pug +++ b/layout/includes/third-party/card-post-count/valine.pug @@ -6,6 +6,7 @@ script. el: '#vcomment', appId: '#{theme.valine.appId}', appKey: '#{theme.valine.appKey}', + serverURLs: '#{theme.valine.serverURLs}' } const valine = new Valine(initData) diff --git a/layout/includes/third-party/comments/disqus.pug b/layout/includes/third-party/comments/disqus.pug index 4c2c727..caa1222 100644 --- a/layout/includes/third-party/comments/disqus.pug +++ b/layout/includes/third-party/comments/disqus.pug @@ -4,7 +4,7 @@ script. function loadDisqus () { var disqus_config = function () { this.page.url = '!{ page.permalink }' - this.page.identifier = '!{ page.path }' + this.page.identifier = '!{ url_for(page.path) }' this.page.title = '!{ disqusPageTitle }' }; @@ -24,6 +24,10 @@ script. (d.head || d.body).appendChild(s); })(); } + + document.getElementById('darkmode').addEventListener('click', () => { + setTimeout(() => window.disqusReset(), 200) + }) } if ('!{theme.comments.use[0]}' === 'Disqus' || !!{theme.comments.lazyload}) { diff --git a/layout/includes/third-party/comments/disqusjs.pug b/layout/includes/third-party/comments/disqusjs.pug index 344be55..1e66555 100644 --- a/layout/includes/third-party/comments/disqusjs.pug +++ b/layout/includes/third-party/comments/disqusjs.pug @@ -10,18 +10,27 @@ script. } function initDisqusjs () { - window.DISQUS = null - new DisqusJS(Object.assign({ + window.disqusjs = null + disqusjs = new DisqusJS(Object.assign({ shortname: '!{theme.disqusjs.shortname}', - identifier: '!{ page.path }', + identifier: '!{ url_for(page.path) }', url: '!{ page.permalink }', title: '!{ disqusjsPageTitle }', apikey: '!{theme.disqusjs.apikey}', },!{JSON.stringify(theme.disqusjs.option)})) + + disqusjs.render(document.getElementById('disqusjs')) + } + + const themeChange = () => { + const ele = document.getElementById('disqus_thread') + if(!ele) return + disqusjs.destroy() + initDisqusjs() } - window.disqusReset = initDisqusjs + document.getElementById('darkmode').addEventListener('click', themeChange) if (window.disqusJsLoad) initDisqusjs() else { @@ -32,7 +41,7 @@ script. } if ('!{theme.comments.use[0]}' === 'Disqusjs' || !!{theme.comments.lazyload}) { - if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('disqus_thread'), loadDisqusjs) + if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('disqusjs'), loadDisqusjs) else loadDisqusjs() } else { diff --git a/layout/includes/third-party/comments/index.pug b/layout/includes/third-party/comments/index.pug index 6c725d6..2ff3fb2 100644 --- a/layout/includes/third-party/comments/index.pug +++ b/layout/includes/third-party/comments/index.pug @@ -22,7 +22,7 @@ hr when 'Valine' #vcomment.vcomment when 'Disqusjs' - #disqus_thread + #disqusjs when 'Livere' #lv-container(data-id="city" data-uid=theme.livere.uid) when 'Gitalk' diff --git a/layout/includes/third-party/comments/twikoo.pug b/layout/includes/third-party/comments/twikoo.pug index 7ae8f63..437a42f 100644 --- a/layout/includes/third-party/comments/twikoo.pug +++ b/layout/includes/third-party/comments/twikoo.pug @@ -39,7 +39,7 @@ script. setTimeout(runFn,0) return } - getScript('!{theme.asset.twikoo}').then(runFn) + getScript('!{url_for(theme.asset.twikoo)}').then(runFn) } if ('!{use[0]}' === 'Twikoo' || !!{lazyload}) { @@ -50,4 +50,4 @@ script. loadTwikoo() } } - })() + })() \ No newline at end of file diff --git a/layout/includes/third-party/math/katex.pug b/layout/includes/third-party/math/katex.pug index 9aa8301..f69e8b8 100644 --- a/layout/includes/third-party/math/katex.pug +++ b/layout/includes/third-party/math/katex.pug @@ -1,6 +1,6 @@ -link(rel="stylesheet" type="text/css" href=theme.asset.katex) +link(rel="stylesheet" type="text/css" href=url_for(theme.asset.katex)) script(src=url_for(theme.asset.katex_copytex)) -link(rel="stylesheet" type="text/css" href=theme.asset.katex_copytex_css) +link(rel="stylesheet" type="text/css" href=url_for(theme.asset.katex_copytex_css)) script. (() => { document.querySelectorAll('#article-container span.katex-display').forEach(item => { diff --git a/layout/includes/third-party/math/mathjax.pug b/layout/includes/third-party/math/mathjax.pug index f8b12bd..688e6dc 100644 --- a/layout/includes/third-party/math/mathjax.pug +++ b/layout/includes/third-party/math/mathjax.pug @@ -37,7 +37,7 @@ script. } const script = document.createElement('script') - script.src = '!{theme.asset.mathjax}' + script.src = '!{url_for(theme.asset.mathjax)}' script.id = 'MathJax-script' script.async = true document.head.appendChild(script) diff --git a/layout/includes/third-party/math/mermaid.pug b/layout/includes/third-party/math/mermaid.pug index 6bd8185..5b7b496 100644 --- a/layout/includes/third-party/math/mermaid.pug +++ b/layout/includes/third-party/math/mermaid.pug @@ -18,7 +18,7 @@ script. } const loadMermaid = () => { - window.loadMermaid ? runMermaid() : getScript('!{theme.asset.mermaid}').then(runMermaid) + window.loadMermaid ? runMermaid() : getScript('!{url_for(theme.asset.mermaid)}').then(runMermaid) } window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid) diff --git a/layout/includes/third-party/newest-comments/twikoo-comment.pug b/layout/includes/third-party/newest-comments/twikoo-comment.pug index 9896b14..e362623 100644 --- a/layout/includes/third-party/newest-comments/twikoo-comment.pug +++ b/layout/includes/third-party/newest-comments/twikoo-comment.pug @@ -43,7 +43,7 @@ script. if (typeof twikoo === 'object') { runTwikoo() } else { - getScript('!{theme.asset.twikoo}').then(runTwikoo) + getScript('!{url_for(theme.asset.twikoo)}').then(runTwikoo) } } diff --git a/layout/includes/third-party/pjax.pug b/layout/includes/third-party/pjax.pug index de318d5..3700010 100644 --- a/layout/includes/third-party/pjax.pug +++ b/layout/includes/third-party/pjax.pug @@ -3,7 +3,7 @@ if theme.pjax.exclude each val in theme.pjax.exclude - pjaxExclude = pjaxExclude + `:not([href="${val}"])` -- let pjaxSelectors = ['title','#config-diff','#body-wrap','#rightside-config-hide','#rightside-config-show','.js-pjax'] +- let pjaxSelectors = ['head > title','#config-diff','#body-wrap','#rightside-config-hide','#rightside-config-show','.js-pjax'] - let choose = theme.comments.use if choose @@ -47,6 +47,7 @@ script. const $bodyClassList = document.body.classList $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode') + typeof disqusjs === 'object' && disqusjs.destroy() }) document.addEventListener('pjax:complete', function () { diff --git a/package.json b/package.json index 151d3c8..3036910 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "4.2.1", + "version": "4.3.0-b1", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/scripts/events/config.js b/scripts/events/config.js index 2342902..78be446 100644 --- a/scripts/events/config.js +++ b/scripts/events/config.js @@ -43,8 +43,8 @@ hexo.extend.filter.register('before_generate', () => { gitalk_css: 'https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.css', blueimp_md5: 'https://cdn.jsdelivr.net/npm/blueimp-md5/js/md5.min.js', valine: 'https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js', - disqusjs: 'https://cdn.jsdelivr.net/npm/disqusjs@1/dist/disqus.js', - disqusjs_css: 'https://cdn.jsdelivr.net/npm/disqusjs@1/dist/disqusjs.css', + disqusjs: 'https://cdn.jsdelivr.net/npm/disqusjs@3/dist/browser/disqusjs.es2015.umd.min.js', + disqusjs_css: 'https://cdn.jsdelivr.net/npm/disqusjs@3/dist/browser/styles/disqusjs.css', twikoo: 'https://cdn.jsdelivr.net/npm/twikoo@1/dist/twikoo.all.min.js', waline_js: 'https://cdn.jsdelivr.net/npm/@waline/client/dist/waline.js', waline_css: 'https://cdn.jsdelivr.net/npm/@waline/client/dist/waline.css', diff --git a/source/css/_mode/darkmode.styl b/source/css/_mode/darkmode.styl index f24a258..0eb9108 100644 --- a/source/css/_mode/darkmode.styl +++ b/source/css/_mode/darkmode.styl @@ -118,8 +118,10 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' fill: alpha(#FFFFFF, .9) !important // Disqusjs 反代模式下的適配 - #disqus_thread + #disqusjs #dsqjs + &:hover, + &:focus, .dsqjs-tab-active, .dsqjs-no-comment color: alpha(#FFFFFF, .7) diff --git a/source/js/main.js b/source/js/main.js index dee553e..c185dbe 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -478,7 +478,6 @@ document.addEventListener('DOMContentLoaded', function () { typeof utterancesTheme === 'function' && utterancesTheme() typeof changeGiscusTheme === 'function' && changeGiscusTheme() typeof FB === 'object' && window.loadFBComment() - window.DISQUS && document.getElementById('disqus_thread').children.length && setTimeout(() => window.disqusReset(), 200) typeof runMermaid === 'function' && window.runMermaid() }, showOrHideBtn: (e) => { // rightside 點擊設置 按鈕 展開 From 08b7cd9dbbbd9010cac167ef1ca634d6a44c7c2f Mon Sep 17 00:00:00 2001 From: qsgy-edge <1794551825@qq.com> Date: Fri, 20 May 2022 16:55:51 +0800 Subject: [PATCH 11/17] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=B3=BB=E5=88=97?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/includes/head/config_site.pug | 3 +++ layout/includes/widget/card_series_post.pug | 15 +++++++++++++++ layout/includes/widget/index.pug | 2 ++ 3 files changed, 20 insertions(+) create mode 100644 layout/includes/widget/card_series_post.pug diff --git a/layout/includes/head/config_site.pug b/layout/includes/head/config_site.pug index 94cbb51..21caa1c 100644 --- a/layout/includes/head/config_site.pug +++ b/layout/includes/head/config_site.pug @@ -6,6 +6,9 @@ else if (page.highlight_shrink === true || page.highlight_shrink === false) isHighlightShrink = page.highlight_shrink else isHighlightShrink = theme.highlight_shrink + if (page.series) + var Series = page.series + var showToc = false if (theme.aside.enable && page.aside !== false) { let tocEnable = false diff --git a/layout/includes/widget/card_series_post.pug b/layout/includes/widget/card_series_post.pug new file mode 100644 index 0000000..9e3fd61 --- /dev/null +++ b/layout/includes/widget/card_series_post.pug @@ -0,0 +1,15 @@ +.card-widget(class='series_post' id='series_post') + .item-headline + i(class='fas fa-car-side') + span 系列文章 #{Series} + .item-content + - let list = site.posts.sort('date', -1) + ul(class='series_post_list') + - list.each(function(article){ + if article.series == Series + - let link = article.link || article.path + - let title = article.title || _p('no_title') + li + a.title(href=url_for(link) title=title)= title + - }) + diff --git a/layout/includes/widget/index.pug b/layout/includes/widget/index.pug index 5f44ae9..94989f0 100644 --- a/layout/includes/widget/index.pug +++ b/layout/includes/widget/index.pug @@ -13,6 +13,8 @@ .sticky_layout if showToc include ./card_post_toc.pug + if Series + include ./card_series_post.pug !=partial('includes/widget/card_recent_post', {}, {cache: true}) !=partial('includes/widget/card_ad', {}, {cache: true}) else From e650f71086d262bf606f27b839a7041ff8d98481 Mon Sep 17 00:00:00 2001 From: Jerry Wong Date: Sun, 22 May 2022 00:02:14 +0800 Subject: [PATCH 12/17] =?UTF-8?q?Revert=20"Feat:=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=B3=BB=E5=88=97=E6=96=87=E7=AB=A0=E7=9B=AE=E5=BD=95"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/includes/head/config_site.pug | 3 --- layout/includes/widget/card_series_post.pug | 15 --------------- layout/includes/widget/index.pug | 2 -- 3 files changed, 20 deletions(-) delete mode 100644 layout/includes/widget/card_series_post.pug diff --git a/layout/includes/head/config_site.pug b/layout/includes/head/config_site.pug index 21caa1c..94cbb51 100644 --- a/layout/includes/head/config_site.pug +++ b/layout/includes/head/config_site.pug @@ -6,9 +6,6 @@ else if (page.highlight_shrink === true || page.highlight_shrink === false) isHighlightShrink = page.highlight_shrink else isHighlightShrink = theme.highlight_shrink - if (page.series) - var Series = page.series - var showToc = false if (theme.aside.enable && page.aside !== false) { let tocEnable = false diff --git a/layout/includes/widget/card_series_post.pug b/layout/includes/widget/card_series_post.pug deleted file mode 100644 index 9e3fd61..0000000 --- a/layout/includes/widget/card_series_post.pug +++ /dev/null @@ -1,15 +0,0 @@ -.card-widget(class='series_post' id='series_post') - .item-headline - i(class='fas fa-car-side') - span 系列文章 #{Series} - .item-content - - let list = site.posts.sort('date', -1) - ul(class='series_post_list') - - list.each(function(article){ - if article.series == Series - - let link = article.link || article.path - - let title = article.title || _p('no_title') - li - a.title(href=url_for(link) title=title)= title - - }) - diff --git a/layout/includes/widget/index.pug b/layout/includes/widget/index.pug index 94989f0..5f44ae9 100644 --- a/layout/includes/widget/index.pug +++ b/layout/includes/widget/index.pug @@ -13,8 +13,6 @@ .sticky_layout if showToc include ./card_post_toc.pug - if Series - include ./card_series_post.pug !=partial('includes/widget/card_recent_post', {}, {cache: true}) !=partial('includes/widget/card_ad', {}, {cache: true}) else From b4d3ea86bb647bf011ea2e155f664134a5758d7c Mon Sep 17 00:00:00 2001 From: Jerry Wong Date: Sun, 22 May 2022 16:20:49 +0800 Subject: [PATCH 13/17] =?UTF-8?q?feat:=20CDN=20=E5=8F=AF=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=82=BA=20unpkg=20fix:=20=E8=A9=95=E8=AB=96=E7=B3=BB=E7=B5=B1?= =?UTF-8?q?=E9=96=8B=E5=95=9F=E6=99=82=20busuanzi=20=E7=9A=84=20page=5Fpv?= =?UTF-8?q?=20=E4=B8=8D=E9=A1=AF=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 6 +- layout/includes/header/post-info.pug | 29 +++---- package.json | 2 +- scripts/events/config.js | 116 ++++++++++++++------------- 4 files changed, 78 insertions(+), 75 deletions(-) diff --git a/_config.yml b/_config.yml index 299f671..b9e6172 100644 --- a/_config.yml +++ b/_config.yml @@ -836,11 +836,11 @@ inject: # 非必要請不要修改 CDN: # The CDN provider of internal scripts (主題內部 js 的 cdn 配置) - # option: local/jsdelivr - # Dev version cannot choose jsdelivr (dev版的主題不能設置為 jsdelivr) + # option: local/jsdelivr/unpkg + # Dev version cannot choose jsdelivr/unpkg (dev版的主題不能設置為 jsdelivr/unpkg) internal_provider: local # The CDN provider of third party scripts (第三方 js 的 cdn 配置) - # option: local/jsdelivr + # option: local/jsdelivr/unpkg # when set it to local, you need to install hexo-butterfly-extjs third_party_provider: jsdelivr option: diff --git a/layout/includes/header/post-info.pug b/layout/includes/header/post-info.pug index 206b993..f7f2174 100644 --- a/layout/includes/header/post-info.pug +++ b/layout/includes/header/post-info.pug @@ -63,23 +63,18 @@ - const commentUse = comments.use if commentUse && !comments.lazyload - case commentUse[0] - when 'Valine' - if theme.valine.visitor - +pvBlock(url_for(page.path),'leancloud_visitors',page.title) - span.leancloud-visitors-count - when 'Waline' - if theme.waline.pageview - +pvBlock('','','') - span.waline-pageview-count(data-path=url_for(page.path)) - when 'Twikoo' - if theme.twikoo.visitor - +pvBlock('','','') - span#twikoo_visitors - default - if theme.busuanzi.page_pv - +pvBlock('','post-meta-pv-cv','') - span#busuanzi_value_page_pv + if commentUse[0] === 'Valine' && theme.valine.visitor + +pvBlock(url_for(page.path),'leancloud_visitors',page.title) + span.leancloud-visitors-count + else if commentUse[0] === 'Waline' && theme.waline.pageview + +pvBlock('','','') + span.waline-pageview-count(data-path=url_for(page.path)) + else if commentUse[0] === 'Twikoo' && theme.twikoo.visitor + +pvBlock('','','') + span#twikoo_visitors + else if theme.busuanzi.page_pv + +pvBlock('','post-meta-pv-cv','') + span#busuanzi_value_page_pv else if theme.busuanzi.page_pv +pvBlock('','post-meta-pv-cv','') span#busuanzi_value_page_pv diff --git a/package.json b/package.json index 3036910..12fbe0b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "4.3.0-b1", + "version": "4.3.0-b2", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/scripts/events/config.js b/scripts/events/config.js index 78be446..ffd5d63 100644 --- a/scripts/events/config.js +++ b/scripts/events/config.js @@ -12,18 +12,22 @@ const path = require('path') hexo.extend.filter.register('before_generate', () => { const themeConfig = hexo.theme.config const { CDN, comments } = themeConfig + const jsdelivr = 'https://cdn.jsdelivr.net/npm/' + const unpkg = 'https://unpkg.com/' /** * Merge CDN */ - const internalSrcCDN = { - main_css: '/css/index.css', - main: `https://cdn.jsdelivr.net/npm/hexo-theme-butterfly@${version}/source/js/main.min.js`, - utils: `https://cdn.jsdelivr.net/npm/hexo-theme-butterfly@${version}/source/js/utils.min.js`, - translate: `https://cdn.jsdelivr.net/npm/hexo-theme-butterfly@${version}/source/js/tw_cn.min.js`, - local_search: `https://cdn.jsdelivr.net/npm/hexo-theme-butterfly@${version}/source/js/search/local-search.min.js`, - algolia_js: `https://cdn.jsdelivr.net/npm/hexo-theme-butterfly@${version}/source/js/search/algolia.min.js`, + const internalSrcCDN = (pre) => { + return { + main_css: '/css/index.css', + main: `${pre}hexo-theme-butterfly@${version}/source/js/main.js`, + utils: `${pre}hexo-theme-butterfly@${version}/source/js/utils.js`, + translate: `${pre}hexo-theme-butterfly@${version}/source/js/tw_cn.js`, + local_search: `${pre}hexo-theme-butterfly@${version}/source/js/search/local-search.js`, + algolia_js: `${pre}hexo-theme-butterfly@${version}/source/js/search/algolia.js`, + } } const internalSrcLocal = { @@ -35,51 +39,53 @@ hexo.extend.filter.register('before_generate', () => { algolia_js: '/js/search/algolia.js', } - const thirdPartySrcCDN = { - algolia_search_v4: 'https://cdn.jsdelivr.net/npm/algoliasearch@4/dist/algoliasearch-lite.umd.js', - instantsearch_v4: 'https://cdn.jsdelivr.net/npm/instantsearch.js@4/dist/instantsearch.production.min.js', - pjax: 'https://cdn.jsdelivr.net/npm/pjax/pjax.min.js', - gitalk: 'https://cdn.jsdelivr.net/npm/gitalk@latest/dist/gitalk.min.js', - gitalk_css: 'https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.css', - blueimp_md5: 'https://cdn.jsdelivr.net/npm/blueimp-md5/js/md5.min.js', - valine: 'https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js', - disqusjs: 'https://cdn.jsdelivr.net/npm/disqusjs@3/dist/browser/disqusjs.es2015.umd.min.js', - disqusjs_css: 'https://cdn.jsdelivr.net/npm/disqusjs@3/dist/browser/styles/disqusjs.css', - twikoo: 'https://cdn.jsdelivr.net/npm/twikoo@1/dist/twikoo.all.min.js', - waline_js: 'https://cdn.jsdelivr.net/npm/@waline/client/dist/waline.js', - waline_css: 'https://cdn.jsdelivr.net/npm/@waline/client/dist/waline.css', - sharejs: 'https://cdn.jsdelivr.net/gh/overtrue/share.js@master/dist/js/social-share.min.js', - sharejs_css: 'https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css', - mathjax: 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js', - katex: 'https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.css', - katex_copytex: 'https://cdn.jsdelivr.net/npm/katex@latest/dist/contrib/copy-tex.min.js', - katex_copytex_css: 'https://cdn.jsdelivr.net/npm/katex@latest/dist/contrib/copy-tex.css', - mermaid: 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js', - canvas_ribbon: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-ribbon.min.js', - canvas_fluttering_ribbon: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js', - canvas_nest: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-nest.min.js', - activate_power_mode: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js', - fireworks: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js', - click_heart: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js', - ClickShowText: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-show-text.min.js', - lazyload: 'https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js', - instantpage: 'https://cdn.jsdelivr.net/npm/instant.page@5/instantpage.min.js', - typed: 'https://cdn.jsdelivr.net/npm/typed.js/lib/typed.min.js', - pangu: 'https://cdn.jsdelivr.net/npm/pangu@4/dist/browser/pangu.min.js', - fancybox_css_v4: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css', - fancybox_v4: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js', - medium_zoom: 'https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js', - snackbar_css: 'https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css', - snackbar: 'https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js', - fontawesomeV6: 'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6/css/all.min.css', - flickr_justified_gallery_js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.js', - flickr_justified_gallery_css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.css', - aplayer_css: 'https://cdn.jsdelivr.net/npm/aplayer@1/dist/APlayer.min.css', - aplayer_js: 'https://cdn.jsdelivr.net/npm/aplayer@1/dist/APlayer.min.js', - meting_js: 'https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js', - prismjs_js: 'https://cdn.jsdelivr.net/npm/prismjs@1/prism.min.js', - prismjs_lineNumber_js: 'https://cdn.jsdelivr.net/npm/prismjs@1/plugins/line-numbers/prism-line-numbers.min.js', - prismjs_autoloader: 'https://cdn.jsdelivr.net/npm/prismjs@1/plugins/autoloader/prism-autoloader.min.js', + const thirdPartySrcCDN = (pre) => { + return { + algolia_search_v4: `${pre}algoliasearch@4/dist/algoliasearch-lite.umd.js`, + instantsearch_v4: `${pre}instantsearch.js@4/dist/instantsearch.production.min.js`, + pjax: `${pre}pjax/pjax.min.js`, + gitalk: `${pre}gitalk@latest/dist/gitalk.min.js`, + gitalk_css: `${pre}gitalk/dist/gitalk.css`, + blueimp_md5: `${pre}blueimp-md5/js/md5.min.js`, + valine: `${pre}valine/dist/Valine.min.js`, + disqusjs: `${pre}disqusjs@3/dist/browser/disqusjs.es2015.umd.min.js`, + disqusjs_css: `${pre}disqusjs@3/dist/browser/styles/disqusjs.css`, + twikoo: `${pre}twikoo@1/dist/twikoo.all.min.js`, + waline_js: `${pre}@waline/client/dist/waline.js`, + waline_css: `${pre}@waline/client/dist/waline.css`, + sharejs: `${pre}butterfly-extsrc@1/ShareJS/dist/js/social-share.min.js`, + sharejs_css: `${pre}butterfly-extsrc@1/ShareJS/dist/css/share.min.css`, + mathjax: `${pre}mathjax@3/es5/tex-mml-chtml.js`, + katex: `${pre}katex@latest/dist/katex.min.css`, + katex_copytex: `${pre}katex@latest/dist/contrib/copy-tex.min.js`, + katex_copytex_css: `${pre}katex@latest/dist/contrib/copy-tex.css`, + mermaid: `${pre}mermaid/dist/mermaid.min.js`, + canvas_ribbon: `${pre}butterfly-extsrc@1/dist/canvas-ribbon.min.js`, + canvas_fluttering_ribbon: `${pre}butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js`, + canvas_nest: `${pre}butterfly-extsrc@1/dist/canvas-nest.min.js`, + activate_power_mode: `${pre}butterfly-extsrc@1/dist/activate-power-mode.min.js`, + fireworks: `${pre}butterfly-extsrc@1/dist/fireworks.min.js`, + click_heart: `${pre}butterfly-extsrc@1/dist/click-heart.min.js`, + ClickShowText: `${pre}butterfly-extsrc@1/dist/click-show-text.min.js`, + lazyload: `${pre}vanilla-lazyload/dist/lazyload.iife.min.js`, + instantpage: `${pre}instant.page@5/instantpage.js`, + typed: `${pre}typed.js/lib/typed.min.js`, + pangu: `${pre}pangu@4/dist/browser/pangu.min.js`, + fancybox_css_v4: `${pre}@fancyapps/ui/dist/fancybox.css`, + fancybox_v4: `${pre}@fancyapps/ui/dist/fancybox.umd.js`, + medium_zoom: `${pre}medium-zoom/dist/medium-zoom.min.js`, + snackbar_css: `${pre}node-snackbar/dist/snackbar.min.css`, + snackbar: `${pre}node-snackbar/dist/snackbar.min.js`, + fontawesomeV6: `${pre}@fortawesome/fontawesome-free@6/css/all.min.css`, + flickr_justified_gallery_js: `${pre}flickr-justified-gallery@2/dist/fjGallery.min.js`, + flickr_justified_gallery_css: `${pre}flickr-justified-gallery@2/dist/fjGallery.css`, + aplayer_css: `${pre}aplayer@1/dist/APlayer.min.css`, + aplayer_js: `${pre}aplayer@1/dist/APlayer.min.js`, + meting_js: `${pre}butterfly-extsrc@1/MetingJS/dist/Meting.min.js`, + prismjs_js: `${pre}prismjs@1/prism.js`, + prismjs_lineNumber_js: `${pre}prismjs@1/plugins/line-numbers/prism-line-numbers.min.js`, + prismjs_autoloader: `${pre}prismjs@1/plugins/autoloader/prism-autoloader.min.js`, + } } // delete null value @@ -94,7 +100,8 @@ hexo.extend.filter.register('before_generate', () => { const defaultVal = (obj, choose) => { if (obj === 'internal') { if (choose === 'local') return internalSrcLocal - else return internalSrcCDN + else if (choose === 'unpkg') return internalSrcCDN(unpkg) + else return internalSrcCDN(jsdelivr) } if (obj === 'external') { @@ -108,7 +115,8 @@ hexo.extend.filter.register('before_generate', () => { }) } catch (e) {} return result - } else return thirdPartySrcCDN + } else if (choose === 'unpkg') return thirdPartySrcCDN(unpkg) + else return thirdPartySrcCDN(jsdelivr) } } From 9a33e23a9c24f8e5e4ba13cf6fb8a5e9b061f5dd Mon Sep 17 00:00:00 2001 From: Jerry Date: Sun, 12 Jun 2022 01:07:09 +0800 Subject: [PATCH 14/17] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=20katex=20copy?= =?UTF-8?q?-tex.css=20feat:=20CDN=E5=8F=AF=E9=85=8D=E7=BD=AE=20cdnjs=20fea?= =?UTF-8?q?t:=20cdn=E5=8F=AF=E8=A8=AD=E7=BD=AE=20version=20=E5=92=8C=20cus?= =?UTF-8?q?tom=20format=20feat:=20=E9=BB=9E=E6=93=8A=E6=AD=B8=E6=AA=94?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E8=B7=B3=E8=BD=89=E5=88=B0=E9=A0=81=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E6=A8=99=E9=A1=8C=E9=A1=AF=E7=A4=BA=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E8=80=8C=E4=B8=8D=E6=98=AF=E2=80=98=E6=AD=B8=E6=AA=94=E2=80=99?= =?UTF-8?q?=E4=BA=8C=E5=AD=97=20closed=20#925=20fix:=20Algolia=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=B2=92=E6=9C=89=E7=B5=90=E6=9E=9C=20closed=20#923?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 12 +- layout/includes/header/index.pug | 2 +- layout/includes/third-party/math/katex.pug | 1 - package.json | 4 +- plugins.yml | 180 +++++++++++++++++++++ scripts/events/cdn.js | 94 +++++++++++ scripts/events/comment.js | 14 ++ scripts/events/config.js | 141 ---------------- scripts/helpers/page.js | 8 +- source/js/search/algolia.js | 12 +- 10 files changed, 316 insertions(+), 152 deletions(-) create mode 100644 plugins.yml create mode 100644 scripts/events/cdn.js create mode 100644 scripts/events/comment.js delete mode 100644 scripts/events/config.js diff --git a/_config.yml b/_config.yml index 15a05a8..e846571 100644 --- a/_config.yml +++ b/_config.yml @@ -843,13 +843,18 @@ inject: # 非必要請不要修改 CDN: # The CDN provider of internal scripts (主題內部 js 的 cdn 配置) - # option: local/jsdelivr/unpkg - # Dev version cannot choose jsdelivr/unpkg (dev版的主題不能設置為 jsdelivr/unpkg) + # option: local/jsdelivr/unpkg/cdnjs/custom + # Dev version can only choose. ( dev版的主題只能設置為 local ) internal_provider: local # The CDN provider of third party scripts (第三方 js 的 cdn 配置) - # option: local/jsdelivr/unpkg + # option: local/jsdelivr/unpkg/cdnjs/custom # when set it to local, you need to install hexo-butterfly-extjs third_party_provider: jsdelivr + # Custom format + # For example: https://cdn.staticfile.org/${cdnjs_name}/${version}/${min_cdnjs_file} + custom_format: + # Add version number to CDN, true or false + version: false option: # main_css: # main: @@ -874,7 +879,6 @@ CDN: # mathjax: # katex: # katex_copytex: - # katex_copytex_css: # mermaid: # canvas_ribbon: # canvas_fluttering_ribbon: diff --git a/layout/includes/header/index.pug b/layout/includes/header/index.pug index f1e3724..18e7dd7 100644 --- a/layout/includes/header/index.pug +++ b/layout/includes/header/index.pug @@ -19,7 +19,7 @@ if !theme.disable_top_img && page.top_img !== false if top_img !== false - var imgSource = top_img && top_img.indexOf('/') !== -1 ? `background-image: url('${url_for(top_img)}')` : `background: ${top_img}` - var bg_img = top_img ? imgSource : '' - - var site_title = is_archive() ? fragment_cache('findArchivesTitle', function(){return findArchivesTitle(theme.menu);}) : page.title || page.tag || page.category || config.title + - var site_title = is_archive() ? findArchivesTitle(page, theme.menu, date) : page.title || page.tag || page.category || config.title - var isHomeClass = is_home() ? 'full_page' : 'not-home-page' - is_post() ? isHomeClass = 'post-bg' : isHomeClass else diff --git a/layout/includes/third-party/math/katex.pug b/layout/includes/third-party/math/katex.pug index f69e8b8..c1f0bd6 100644 --- a/layout/includes/third-party/math/katex.pug +++ b/layout/includes/third-party/math/katex.pug @@ -1,6 +1,5 @@ link(rel="stylesheet" type="text/css" href=url_for(theme.asset.katex)) script(src=url_for(theme.asset.katex_copytex)) -link(rel="stylesheet" type="text/css" href=url_for(theme.asset.katex_copytex_css)) script. (() => { document.querySelectorAll('#article-container span.katex-display').forEach(item => { diff --git a/package.json b/package.json index 12fbe0b..dac10e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "4.3.0-b2", + "version": "4.3.0-b3", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { @@ -23,7 +23,7 @@ "email": "my@crazywong.com" }, "dependencies": { - "hexo-renderer-stylus": "^2.0.1", + "hexo-renderer-stylus": "^2.1.0", "hexo-renderer-pug": "^3.0.0" }, "homepage": "https://butterfly.js.org/", diff --git a/plugins.yml b/plugins.yml new file mode 100644 index 0000000..9d29626 --- /dev/null +++ b/plugins.yml @@ -0,0 +1,180 @@ +algolia_search_v4: + name: algoliasearch + file: dist/algoliasearch-lite.umd.js + version: 4.13.1 +instantsearch_v4: + name: instantsearch.js + file: dist/instantsearch.production.min.js + version: 4.41.0 +pjax: + name: pjax + file: pjax.min.js + version: 0.2.8 +gitalk: + name: gitalk + file: dist/gitalk.min.js + version: 1.7.2 +gitalk_css: + name: gitalk + file: dist/gitalk.css + version: 1.7.2 +blueimp_md5: + name: blueimp-md5 + file: js/md5.min.js + version: 2.19.0 +valine: + name: valine + file: dist/Valine.min.js + version: 1.4.18 +disqusjs: + name: disqusjs + file: dist/browser/disqusjs.es2015.umd.min.js + version: 3.0.1 +disqusjs_css: + name: disqusjs + file: dist/browser/styles/disqusjs.css + version: 3.0.1 +twikoo: + name: twikoo + file: dist/twikoo.all.min.js + version: 1.5.11 +waline_js: + name: '@waline/client' + file: dist/waline.js + other_name: waline + version: 2.5.1 +waline_css: + name: '@waline/client' + file: dist/waline.css + other_name: waline + version: 2.5.1 +sharejs: + name: butterfly-extsrc + file: sharejs/dist/js/social-share.min.js + version: 1.1.3 +sharejs_css: + name: butterfly-extsrc + file: sharejs/dist/css/share.min.css + version: 1.1.3 +mathjax: + name: mathjax + file: es5/tex-mml-chtml.js + version: 3.2.2 +katex: + name: katex + file: dist/katex.min.css + other_name: KaTeX + version: 0.16.0 +katex_copytex: + name: katex + file: dist/contrib/copy-tex.min.js + other_name: KaTeX + version: 0.16.0 +mermaid: + name: mermaid + file: dist/mermaid.min.js + version: 9.1.1 +canvas_ribbon: + name: butterfly-extsrc + file: dist/canvas-ribbon.min.js + version: 1.1.3 +canvas_fluttering_ribbon: + name: butterfly-extsrc + file: dist/canvas-fluttering-ribbon.min.js + version: 1.1.3 +canvas_nest: + name: butterfly-extsrc + file: dist/canvas-nest.min.js + version: 1.1.3 +activate_power_mode: + name: butterfly-extsrc + file: dist/activate-power-mode.min.js + version: 1.1.3 +fireworks: + name: butterfly-extsrc + file: dist/fireworks.min.js + version: 1.1.3 +click_heart: + name: butterfly-extsrc + file: dist/click-heart.min.js + version: 1.1.3 +ClickShowText: + name: butterfly-extsrc + file: dist/click-show-text.min.js + version: 1.1.3 +lazyload: + name: vanilla-lazyload + file: dist/lazyload.iife.min.js + version: 17.8.2 +instantpage: + name: instant.page + file: instantpage.js + version: 5.1.0 +typed: + name: typed.js + file: lib/typed.min.js + version: 2.0.12 +pangu: + name: pangu + file: dist/browser/pangu.min.js + version: 4.0.7 +fancybox_css_v4: + name: '@fancyapps/ui' + file: dist/fancybox.css + version: 4.0.27 +fancybox_v4: + name: '@fancyapps/ui' + file: dist/fancybox.umd.js + version: 4.0.27 +medium_zoom: + name: medium-zoom + file: dist/medium-zoom.min.js + version: 1.0.6 +snackbar_css: + name: node-snackbar + file: dist/snackbar.min.css + version: 0.1.16 +snackbar: + name: node-snackbar + file: dist/snackbar.min.js + version: 0.1.16 +fontawesomeV6: + name: '@fortawesome/fontawesome-free' + file: css/all.min.css + other_name: font-awesome + version: 6.1.1 +flickr_justified_gallery_js: + name: flickr-justified-gallery + file: dist/fjGallery.min.js + version: 2.0.0 +flickr_justified_gallery_css: + name: flickr-justified-gallery + file: dist/fjGallery.css + version: 2.0.0 +aplayer_css: + name: aplayer + file: dist/APlayer.min.css + version: 1.10.1 +aplayer_js: + name: aplayer + file: dist/APlayer.min.js + version: 1.10.1 +meting_js: + name: butterfly-extsrc + file: metingjs/dist/Meting.min.js + version: 1.1.3 +prismjs_js: + name: prismjs + file: prism.js + other_name: prism + version: 1.28.0 +prismjs_lineNumber_js: + name: prismjs + file: plugins/line-numbers/prism-line-numbers.min.js + other_name: prism + version: 1.28.0 +prismjs_autoloader: + name: prismjs + file: plugins/autoloader/prism-autoloader.min.js + other_name: prism + version: 1.28.0 diff --git a/scripts/events/cdn.js b/scripts/events/cdn.js new file mode 100644 index 0000000..7d77e63 --- /dev/null +++ b/scripts/events/cdn.js @@ -0,0 +1,94 @@ +/** + * Butterfly + * Merge CDN + */ + +'use strict' + +const { version } = require('../../package.json') +const path = require('path') + +hexo.extend.filter.register('before_generate', () => { + const themeConfig = hexo.theme.config + const { CDN } = themeConfig + + const thirdPartySrc = hexo.render.renderSync({ path: path.join(hexo.theme_dir,'/plugins.yml'), engine: 'yaml'}) + const internalSrc = { + main: { + name: 'hexo-theme-butterfly', + file: 'js/main.js', + version + }, + utils: { + name: 'hexo-theme-butterfly', + file: 'js/utils.js', + version + }, + translate: { + name: 'hexo-theme-butterfly', + file: 'js/tw_cn.js', + version + }, + local_search: { + name: 'hexo-theme-butterfly', + file: 'js/search/local-search.js', + version + }, + algolia_js: { + name: 'hexo-theme-butterfly', + file: 'js/search/algolia.js', + version + } + } + + const minFile = (file) => { + return file.replace(/(? '.min' + ext) + } + + const createCDNLink = (data, type, cond = '') => { + Object.keys(data).map(key => { + let { name, version, file, other_name } = data[key] + + const min_file = minFile(file) + const cdnjs_name = other_name || name + 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 value = { + version, + name, + file, + cdnjs_file, + min_file, + min_cdnjs_file, + cdnjs_name + } + const cdnSource = { + local: cond === 'internal' ? cdnjs_file : `/pluginsSrc/${name}/${file}`, + 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}`, + custom: (CDN.custom_format || '').replace(/\$\{(.+?)\}/g, (match, $1) => value[$1]) + } + + data[key] = cdnSource[type] + }) + + if (cond === 'internal') data['main_css'] = 'css/index.css' + return data + } + + // delete null value + const deleteNullValue = obj => { + if (!obj) return + for (const i in obj) { + obj[i] === null && delete obj[i] + } + return obj + } + + themeConfig.asset = Object.assign(createCDNLink(internalSrc,CDN.internal_provider,'internal'), + createCDNLink(thirdPartySrc,CDN.third_party_provider), deleteNullValue(CDN.option)) +}) diff --git a/scripts/events/comment.js b/scripts/events/comment.js new file mode 100644 index 0000000..b1ef856 --- /dev/null +++ b/scripts/events/comment.js @@ -0,0 +1,14 @@ +/** + * Capitalize the first letter of comment name + */ + +hexo.extend.filter.register('before_generate', () => { + const themeConfig = hexo.theme.config + let { use } = themeConfig.comments + if (!use) return + if (typeof use === 'string') { + use = use.split(',') + } + const newArray = use.map(item => item.toLowerCase().replace(/\b[a-z]/g, s => s.toUpperCase())) + themeConfig.comments.use = newArray +}) \ No newline at end of file diff --git a/scripts/events/config.js b/scripts/events/config.js deleted file mode 100644 index ffd5d63..0000000 --- a/scripts/events/config.js +++ /dev/null @@ -1,141 +0,0 @@ -/** - * Butterfly - * 1. Merge CDN - * 2. Capitalize the first letter of comment name - */ - -'use strict' - -const { version } = require('../../package.json') -const path = require('path') - -hexo.extend.filter.register('before_generate', () => { - const themeConfig = hexo.theme.config - const { CDN, comments } = themeConfig - const jsdelivr = 'https://cdn.jsdelivr.net/npm/' - const unpkg = 'https://unpkg.com/' - - /** - * Merge CDN - */ - - const internalSrcCDN = (pre) => { - return { - main_css: '/css/index.css', - main: `${pre}hexo-theme-butterfly@${version}/source/js/main.js`, - utils: `${pre}hexo-theme-butterfly@${version}/source/js/utils.js`, - translate: `${pre}hexo-theme-butterfly@${version}/source/js/tw_cn.js`, - local_search: `${pre}hexo-theme-butterfly@${version}/source/js/search/local-search.js`, - algolia_js: `${pre}hexo-theme-butterfly@${version}/source/js/search/algolia.js`, - } - } - - const internalSrcLocal = { - main_css: '/css/index.css', - main: '/js/main.js', - utils: '/js/utils.js', - translate: '/js/tw_cn.js', - local_search: '/js/search/local-search.js', - algolia_js: '/js/search/algolia.js', - } - - const thirdPartySrcCDN = (pre) => { - return { - algolia_search_v4: `${pre}algoliasearch@4/dist/algoliasearch-lite.umd.js`, - instantsearch_v4: `${pre}instantsearch.js@4/dist/instantsearch.production.min.js`, - pjax: `${pre}pjax/pjax.min.js`, - gitalk: `${pre}gitalk@latest/dist/gitalk.min.js`, - gitalk_css: `${pre}gitalk/dist/gitalk.css`, - blueimp_md5: `${pre}blueimp-md5/js/md5.min.js`, - valine: `${pre}valine/dist/Valine.min.js`, - disqusjs: `${pre}disqusjs@3/dist/browser/disqusjs.es2015.umd.min.js`, - disqusjs_css: `${pre}disqusjs@3/dist/browser/styles/disqusjs.css`, - twikoo: `${pre}twikoo@1/dist/twikoo.all.min.js`, - waline_js: `${pre}@waline/client/dist/waline.js`, - waline_css: `${pre}@waline/client/dist/waline.css`, - sharejs: `${pre}butterfly-extsrc@1/ShareJS/dist/js/social-share.min.js`, - sharejs_css: `${pre}butterfly-extsrc@1/ShareJS/dist/css/share.min.css`, - mathjax: `${pre}mathjax@3/es5/tex-mml-chtml.js`, - katex: `${pre}katex@latest/dist/katex.min.css`, - katex_copytex: `${pre}katex@latest/dist/contrib/copy-tex.min.js`, - katex_copytex_css: `${pre}katex@latest/dist/contrib/copy-tex.css`, - mermaid: `${pre}mermaid/dist/mermaid.min.js`, - canvas_ribbon: `${pre}butterfly-extsrc@1/dist/canvas-ribbon.min.js`, - canvas_fluttering_ribbon: `${pre}butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js`, - canvas_nest: `${pre}butterfly-extsrc@1/dist/canvas-nest.min.js`, - activate_power_mode: `${pre}butterfly-extsrc@1/dist/activate-power-mode.min.js`, - fireworks: `${pre}butterfly-extsrc@1/dist/fireworks.min.js`, - click_heart: `${pre}butterfly-extsrc@1/dist/click-heart.min.js`, - ClickShowText: `${pre}butterfly-extsrc@1/dist/click-show-text.min.js`, - lazyload: `${pre}vanilla-lazyload/dist/lazyload.iife.min.js`, - instantpage: `${pre}instant.page@5/instantpage.js`, - typed: `${pre}typed.js/lib/typed.min.js`, - pangu: `${pre}pangu@4/dist/browser/pangu.min.js`, - fancybox_css_v4: `${pre}@fancyapps/ui/dist/fancybox.css`, - fancybox_v4: `${pre}@fancyapps/ui/dist/fancybox.umd.js`, - medium_zoom: `${pre}medium-zoom/dist/medium-zoom.min.js`, - snackbar_css: `${pre}node-snackbar/dist/snackbar.min.css`, - snackbar: `${pre}node-snackbar/dist/snackbar.min.js`, - fontawesomeV6: `${pre}@fortawesome/fontawesome-free@6/css/all.min.css`, - flickr_justified_gallery_js: `${pre}flickr-justified-gallery@2/dist/fjGallery.min.js`, - flickr_justified_gallery_css: `${pre}flickr-justified-gallery@2/dist/fjGallery.css`, - aplayer_css: `${pre}aplayer@1/dist/APlayer.min.css`, - aplayer_js: `${pre}aplayer@1/dist/APlayer.min.js`, - meting_js: `${pre}butterfly-extsrc@1/MetingJS/dist/Meting.min.js`, - prismjs_js: `${pre}prismjs@1/prism.js`, - prismjs_lineNumber_js: `${pre}prismjs@1/plugins/line-numbers/prism-line-numbers.min.js`, - prismjs_autoloader: `${pre}prismjs@1/plugins/autoloader/prism-autoloader.min.js`, - } - } - - // delete null value - const deleteNullValue = obj => { - if (!obj) return - for (const i in obj) { - obj[i] === null && delete obj[i] - } - return obj - } - - const defaultVal = (obj, choose) => { - if (obj === 'internal') { - if (choose === 'local') return internalSrcLocal - else if (choose === 'unpkg') return internalSrcCDN(unpkg) - else return internalSrcCDN(jsdelivr) - } - - if (obj === 'external') { - if (choose === 'local') { - let result = {} - try { - const data = path.join(hexo.plugin_dir,'hexo-butterfly-extjs/plugins.yml') - result = hexo.render.renderSync({ path: data, engine: 'yaml'}) - Object.keys(result).map(key => { - result[key] = '/pluginsSrc/' + result[key] - }) - } catch (e) {} - return result - } else if (choose === 'unpkg') return thirdPartySrcCDN(unpkg) - else return thirdPartySrcCDN(jsdelivr) - } - } - - themeConfig.asset = Object.assign(defaultVal('internal', CDN.internal_provider), - defaultVal('external', CDN.third_party_provider), deleteNullValue(CDN.option)) - - /** - * Capitalize the first letter of comment name - */ - - let { use } = comments - - if (!use) return - - if (typeof use === 'string') { - use = use.split(',') - } - - const newArray = use.map(item => item.toLowerCase().replace(/\b[a-z]/g, s => s.toUpperCase())) - - themeConfig.comments.use = newArray -}) diff --git a/scripts/helpers/page.js b/scripts/helpers/page.js index 35c4149..aa2b74b 100644 --- a/scripts/helpers/page.js +++ b/scripts/helpers/page.js @@ -71,7 +71,13 @@ hexo.extend.helper.register('injectHtml', function (data) { return result }) -hexo.extend.helper.register('findArchivesTitle', function (menu) { +hexo.extend.helper.register('findArchivesTitle', function (page, menu, date) { + if (page.year) { + const dateStr = page.month ? `${page.year}-${page.month}` : `${page.year}` + const date_format = page.month ? hexo.theme.config.aside.card_archives.format : 'YYYY' + return date(dateStr, date_format) + } + const defaultTitle = this._p('page.archives') if (!menu) return defaultTitle diff --git a/source/js/search/algolia.js b/source/js/search/algolia.js index 530aa4d..f0b9f3a 100644 --- a/source/js/search/algolia.js +++ b/source/js/search/algolia.js @@ -91,11 +91,19 @@ window.addEventListener('load', () => { templates: { item(data) { const link = data.permalink ? data.permalink : (GLOBAL_CONFIG.root + data.path) + const result = data._highlightResult + const content = result.contentStripTruncate + ? cutContent(result.contentStripTruncate.value) + : result.contentStrip + ? cutContent(result.contentStrip.value) + : result.content + ? cutContent(result.content.value) + : '' return ` - ${data._highlightResult.title.value || 'no-title'} + ${result.title.value || 'no-title'} -

${cutContent(data._highlightResult.contentStripTruncate.value)}

` +

${content}

` }, empty: function (data) { return ( From 931a0ba82da283966dd3f8fb77a47d14699bd559 Mon Sep 17 00:00:00 2001 From: Jerry Date: Fri, 17 Jun 2022 01:01:46 +0800 Subject: [PATCH 15/17] =?UTF-8?q?breaking=20changes:=20archives=20?= =?UTF-8?q?=E9=9A=B1=E8=97=8F=20aside=20=E8=A8=AD=E7=BD=AE=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=20feat:=20tag=20=E5=92=8C=20category=20=E9=A0=81?= =?UTF-8?q?=E9=9D=A2=E5=8F=AF=E8=A8=AD=E7=BD=AE=E9=9A=B1=E8=97=8F=20aside?= =?UTF-8?q?=20feat:=20=E5=AD=90=E6=AD=B8=E6=AA=94=E9=A0=81=E9=9D=A2?= =?UTF-8?q?=E9=A1=AF=E7=A4=BA=E7=9A=84=E6=96=87=E7=AB=A0=E6=95=B8=E9=87=8F?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E9=A1=AF=E7=A4=BA=E7=B8=BD=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E6=95=B8=E9=87=8F=EF=BC=8C=E8=80=8C=E6=98=AF=E5=B0=8D=E6=87=89?= =?UTF-8?q?=E7=9A=84=E5=AD=90=E6=AD=B8=E6=AA=94=E6=96=87=E7=AB=A0=E6=95=B8?= =?UTF-8?q?=E9=87=8F=20feat:=20=E7=82=BA=E4=B8=80=E4=BA=9B=E6=95=B8?= =?UTF-8?q?=E6=93=9A=E5=8A=A0=E8=BC=89=E5=A2=9E=E5=8A=A0=20loading=20?= =?UTF-8?q?=E9=A1=AF=E7=A4=BA=20improvement:=20=E4=BF=AE=E6=94=B9=20note?= =?UTF-8?q?=20=E5=9C=96=E6=A8=99=20class=20=E5=90=8D=E5=AD=97=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E7=AC=AC=E4=B8=89=E6=96=B9=E5=9C=96=E6=A8=99?= =?UTF-8?q?=E8=A6=86=E8=93=8B=E4=B8=BB=E9=A1=8C=E6=A8=A3=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 5 ++- layout/archive.pug | 3 +- layout/includes/header/post-info.pug | 15 ++++++- layout/includes/layout.pug | 2 +- layout/includes/mixins/post-ui.pug | 9 +++- layout/includes/widget/card_webinfo.pug | 6 ++- package.json | 2 +- plugins.yml | 16 ++++--- scripts/helpers/findArchiveLength.js | 58 +++++++++++++++++++++++++ scripts/tag/note.js | 2 +- source/css/_tags/note.styl | 2 +- 11 files changed, 104 insertions(+), 16 deletions(-) create mode 100644 scripts/helpers/findArchiveLength.js diff --git a/_config.yml b/_config.yml index e846571..1cf5d95 100644 --- a/_config.yml +++ b/_config.yml @@ -628,7 +628,10 @@ aside: button: true mobile: true # display on mobile position: right # left or right - archives: true + display: + archive: true + tag: true + category: true card_author: enable: true description: diff --git a/layout/archive.pug b/layout/archive.pug index faa485c..815cdd1 100644 --- a/layout/archive.pug +++ b/layout/archive.pug @@ -3,6 +3,7 @@ extends includes/layout.pug block content include ./includes/mixins/article-sort.pug #archive - .article-sort-title= _p('page.articles') + ' - ' + site.posts.length + - const archiveLength = findArchiveLength(fragment_cache) + .article-sort-title= _p('page.articles') + ' - ' + archiveLength +articleSort(page.posts) include includes/pagination.pug \ No newline at end of file diff --git a/layout/includes/header/post-info.pug b/layout/includes/header/post-info.pug index b75f804..6b951c4 100644 --- a/layout/includes/header/post-info.pug +++ b/layout/includes/header/post-info.pug @@ -66,18 +66,23 @@ if commentUse[0] === 'Valine' && theme.valine.visitor +pvBlock(url_for(page.path),'leancloud_visitors',page.title) span.leancloud-visitors-count + i.fa-solid.fa-spinner.fa-spin else if commentUse[0] === 'Waline' && theme.waline.pageview +pvBlock('','','') span.waline-pageview-count(data-path=url_for(page.path)) + i.fa-solid.fa-spinner.fa-spin else if commentUse[0] === 'Twikoo' && theme.twikoo.visitor +pvBlock('','','') span#twikoo_visitors + i.fa-solid.fa-spinner.fa-spin else if theme.busuanzi.page_pv +pvBlock('','post-meta-pv-cv','') span#busuanzi_value_page_pv + i.fa-solid.fa-spinner.fa-spin else if theme.busuanzi.page_pv +pvBlock('','post-meta-pv-cv','') span#busuanzi_value_page_pv + i.fa-solid.fa-spinner.fa-spin if comments.count && !comments.lazyload && page.comments !== false && comments.use - var whichCount = comments.use[0] @@ -95,31 +100,39 @@ +countBlock span.disqus-comment-count a(href=full_url_for(page.path) + '#disqus_thread') + i.fa-solid.fa-spinner.fa-spin when 'Disqusjs' +countBlock a(href=full_url_for(page.path) + '#disqusjs') span.disqus-comment-count(data-disqus-url=full_url_for(page.path)) + i.fa-solid.fa-spinner.fa-spin when 'Valine' +countBlock a(href=url_for(page.path) + '#post-comment' itemprop="discussionUrl") span.valine-comment-count(data-xid=url_for(page.path) itemprop="commentCount") + i.fa-solid.fa-spinner.fa-spin when 'Waline' +countBlock a(href=url_for(page.path) + '#post-comment') span.waline-comment-count(data-path=url_for(page.path)) + i.fa-solid.fa-spinner.fa-spin when 'Gitalk' +countBlock a(href=url_for(page.path) + '#post-comment') span.gitalk-comment-count + i.fa-solid.fa-spinner.fa-spin when 'Twikoo' +countBlock a(href=url_for(page.path) + '#post-comment') span#twikoo-count + i.fa-solid.fa-spinner.fa-spin when 'Facebook Comments' +countBlock a(href=url_for(page.path) + '#post-comment') span.fb-comments-count(data-href=urlNoIndex()) + i.fa-solid.fa-spinner.fa-spin when 'Remark42' +countBlock a(href=url_for(page.path) + '#post-comment') - span.remark42__counter(data-url=urlNoIndex()) \ No newline at end of file + span.remark42__counter(data-url=urlNoIndex()) + i.fa-solid.fa-spinner.fa-spin \ No newline at end of file diff --git a/layout/includes/layout.pug b/layout/includes/layout.pug index aabce94..414b45d 100644 --- a/layout/includes/layout.pug +++ b/layout/includes/layout.pug @@ -1,5 +1,5 @@ - var htmlClassHideAside = theme.aside.enable && theme.aside.hide ? 'hide-aside' : '' -- page.aside = is_archive() ? theme.aside.archives : page.aside +- page.aside = is_archive() ? theme.aside.display.archive: is_category() ? theme.aside.display.category : is_tag() ? theme.aside.display.tag : page.aside - var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : '' - var pageType = is_post() ? 'post' : 'page' diff --git a/layout/includes/mixins/post-ui.pug b/layout/includes/mixins/post-ui.pug index ef2b10b..3d8619b 100644 --- a/layout/includes/mixins/post-ui.pug +++ b/layout/includes/mixins/post-ui.pug @@ -5,7 +5,7 @@ mixin postUI(posts) let link = article.link || article.path let title = article.title || _p('no_title') const position = theme.cover.position - let leftOrRight = position === 'both' + let leftOrRight = position === 'both' ? index%2 == 0 ? 'left' : 'right' : position === 'left' ? 'left' : 'right' let post_cover = article.cover @@ -72,29 +72,36 @@ mixin postUI(posts) when 'Disqus' +countBlockInIndex a(href=full_url_for(link) + '#disqus_thread') + i.fa-solid.fa-spinner.fa-spin when 'Disqusjs' +countBlockInIndex a(href=full_url_for(link) + '#disqusjs') span.disqus-comment-count(data-disqus-url=full_url_for(link)) + i.fa-solid.fa-spinner.fa-spin when 'Valine' +countBlockInIndex a(href=url_for(link) + '#post-comment') span.valine-comment-count(data-xid=url_for(link)) + i.fa-solid.fa-spinner.fa-spin when 'Waline' +countBlockInIndex a(href=url_for(link) + '#post-comment') span.waline-comment-count(id=url_for(link)) + i.fa-solid.fa-spinner.fa-spin when 'Twikoo' +countBlockInIndex a.twikoo-count(href=url_for(link) + '#post-comment') + i.fa-solid.fa-spinner.fa-spin when 'Facebook Comments' +countBlockInIndex a(href=url_for(link) + '#post-comment') span.fb-comments-count(data-href=urlNoIndex(article.permalink)) + i.fa-solid.fa-spinner.fa-spin when 'Remark42' +countBlockInIndex a(href=url_for(link) + '#post-comment') span.remark42__counter(data-url=urlNoIndex(article.permalink)) + i.fa-solid.fa-spinner.fa-spin //- Display the article introduction on homepage case theme.index_post_content.method diff --git a/layout/includes/widget/card_webinfo.pug b/layout/includes/widget/card_webinfo.pug index 3bff545..9ff3de0 100644 --- a/layout/includes/widget/card_webinfo.pug +++ b/layout/includes/widget/card_webinfo.pug @@ -12,20 +12,24 @@ if theme.aside.card_webinfo.enable .webinfo-item .item-name= _p('aside.card_webinfo.runtime.name') + " :" .item-count#runtimeshow(data-publishDate=date_xml(theme.runtimeshow.publish_date)) + i.fa-solid.fa-spinner.fa-spin if theme.wordcount.enable && theme.wordcount.total_wordcount .webinfo-item .item-name=_p('aside.card_webinfo.site_wordcount') + " :" .item-count=totalcount(site) - if theme.busuanzi.site_uv + if theme.busuanzi.site_uv .webinfo-item .item-name= _p('aside.card_webinfo.site_uv_name') + " :" .item-count#busuanzi_value_site_uv + i.fa-solid.fa-spinner.fa-spin if theme.busuanzi.site_pv .webinfo-item .item-name= _p('aside.card_webinfo.site_pv_name') + " :" .item-count#busuanzi_value_site_pv + i.fa-solid.fa-spinner.fa-spin if theme.aside.card_webinfo.last_push_date .webinfo-item .item-name= _p('aside.card_webinfo.last_push_date.name') + " :" .item-count#last-push-date(data-lastPushDate=date_xml(Date.now())) + i.fa-solid.fa-spinner.fa-spin diff --git a/package.json b/package.json index dac10e9..1ac9e18 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "4.3.0-b3", + "version": "4.3.0-b4", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/plugins.yml b/plugins.yml index 9d29626..d9043d9 100644 --- a/plugins.yml +++ b/plugins.yml @@ -5,7 +5,7 @@ algolia_search_v4: instantsearch_v4: name: instantsearch.js file: dist/instantsearch.production.min.js - version: 4.41.0 + version: 4.41.2 pjax: name: pjax file: pjax.min.js @@ -42,12 +42,12 @@ waline_js: name: '@waline/client' file: dist/waline.js other_name: waline - version: 2.5.1 + version: 2.6.1 waline_css: name: '@waline/client' file: dist/waline.css other_name: waline - version: 2.5.1 + version: 2.6.1 sharejs: name: butterfly-extsrc file: sharejs/dist/js/social-share.min.js @@ -73,7 +73,7 @@ katex_copytex: mermaid: name: mermaid file: dist/mermaid.min.js - version: 9.1.1 + version: 9.1.2 canvas_ribbon: name: butterfly-extsrc file: dist/canvas-ribbon.min.js @@ -122,10 +122,12 @@ fancybox_css_v4: name: '@fancyapps/ui' file: dist/fancybox.css version: 4.0.27 + other_name: fancyapps-ui fancybox_v4: name: '@fancyapps/ui' file: dist/fancybox.umd.js version: 4.0.27 + other_name: fancyapps-ui medium_zoom: name: medium-zoom file: dist/medium-zoom.min.js @@ -146,11 +148,11 @@ fontawesomeV6: flickr_justified_gallery_js: name: flickr-justified-gallery file: dist/fjGallery.min.js - version: 2.0.0 + version: 2.1.2 flickr_justified_gallery_css: name: flickr-justified-gallery file: dist/fjGallery.css - version: 2.0.0 + version: 2.1.2 aplayer_css: name: aplayer file: dist/APlayer.min.css @@ -177,4 +179,4 @@ prismjs_autoloader: name: prismjs file: plugins/autoloader/prism-autoloader.min.js other_name: prism - version: 1.28.0 + version: 1.28.0 \ No newline at end of file diff --git a/scripts/helpers/findArchiveLength.js b/scripts/helpers/findArchiveLength.js new file mode 100644 index 0000000..e55dc0f --- /dev/null +++ b/scripts/helpers/findArchiveLength.js @@ -0,0 +1,58 @@ +hexo.extend.helper.register('findArchiveLength', function (func) { + const allPostsLength = this.site.posts.length; + if (hexo.config.archive_generator && hexo.config.archive_generator.enable === false ) return allPostsLength + const { yearly, monthly, daily } = hexo.config.archive_generator + const { year, month, day } = this.page + if (yearly === false || !year) return allPostsLength + + const posts = this.site.posts.sort('date') + + const compareFunc = (type,y1,m1,d1,y2,m2,d2) => { + if (type === 'year') { + return y1 === y2 + } else if (type === 'month') { + return y1 === y2 && m1 === m2 + } else if (type === 'day') { + return y1 === y2 && m1 === m2 && d1 === d2 + } + } + + const generateDateObj = (type) => { + let dateObj = [] + let length = 0 + + posts.forEach(post => { + let date = post.date.clone() + const year = date.year() + const month = date.month() + 1 + const day = date.date() + let lastData = dateObj[length - 1] + + if (!lastData || !compareFunc(type, lastData.year, lastData.month, lastData.day, year, month, day)) { + const name = type === 'year' ? year : type === 'month' ? `${year}-${month}` : `${year}-${month}-${day}` + length = dateObj.push({ + name, + year, + month, + day, + count: 1 + }) + } else { + lastData.count++ + } + }); + + return dateObj + } + + const data = func('createArchiveObj', ()=> { + const yearObj = yearly ? generateDateObj('year') : [] + const monthObj = monthly ? generateDateObj('month') : [] + const dayObj = daily ? generateDateObj('day') : [] + const fullObj = [...yearObj, ...monthObj, ...dayObj] + return fullObj + }) + + const name = month ? day ? `${year}-${month}-${day}` : `${year}-${month}` : year + return data.find(item => item.name === name).count +}) \ No newline at end of file diff --git a/scripts/tag/note.js b/scripts/tag/note.js index ec4e8b5..aa19129 100644 --- a/scripts/tag/note.js +++ b/scripts/tag/note.js @@ -17,7 +17,7 @@ function postNote (args, content) { const iconArray = args[args.length - 2] if (iconArray && iconArray.startsWith('fa')) { icon = `` - args[args.length - 2] = 'icon' + args[args.length - 2] = 'icon-padding' } return `
${icon + hexo.render.renderSync({ text: content, engine: 'markdown' })}
` diff --git a/source/css/_tags/note.styl b/source/css/_tags/note.styl index eaba7af..efd3781 100644 --- a/source/css/_tags/note.styl +++ b/source/css/_tags/note.styl @@ -7,7 +7,7 @@ if hexo-config('note.border_radius') is a 'unit' border-radius: unit(hexo-config('note.border_radius'), px) - &.icon + &.icon-padding padding-left: 3em & > .note-icon From 91d49fe7a2b7dd113dc632e9958d90f09ea08801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?CC=E5=BA=B7=E7=BA=B3=E7=99=BE=E5=B7=9D?= Date: Sat, 18 Jun 2022 18:35:31 +0800 Subject: [PATCH 16/17] =?UTF-8?q?fix=EF=BC=9A=E4=BE=A7=E8=BE=B9=E6=A0=8F?= =?UTF-8?q?=E5=BD=92=E6=A1=A3=E5=8D=A1=E7=89=87=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/css/_layout/aside.styl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/css/_layout/aside.styl b/source/css/_layout/aside.styl index bc1675a..5d7e6ca 100644 --- a/source/css/_layout/aside.styl +++ b/source/css/_layout/aside.styl @@ -403,7 +403,7 @@ if hexo-config('aside.card_archives.sort_order') .card-archives - order: hexo-config('aside.card-archives.sort_order') + order: hexo-config('aside.card_archives.sort_order') if hexo-config('aside.card_webinfo.sort_order') .card-webinfo From fba180afaf7b23b9af00b591675ae6e30e846ea9 Mon Sep 17 00:00:00 2001 From: Jerry Date: Fri, 24 Jun 2022 02:08:26 +0800 Subject: [PATCH 17/17] update 4.3.0 --- _config.yml | 8 ++++++-- package.json | 2 +- plugins.yml | 4 ++-- source/css/_page/homepage.styl | 3 +++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/_config.yml b/_config.yml index 1cf5d95..c960cc1 100644 --- a/_config.yml +++ b/_config.yml @@ -849,15 +849,19 @@ CDN: # option: local/jsdelivr/unpkg/cdnjs/custom # Dev version can only choose. ( dev版的主題只能設置為 local ) internal_provider: local + # The CDN provider of third party scripts (第三方 js 的 cdn 配置) # option: local/jsdelivr/unpkg/cdnjs/custom # when set it to local, you need to install hexo-butterfly-extjs third_party_provider: jsdelivr + + # Add version number to CDN, true or false + version: false + # Custom format # For example: https://cdn.staticfile.org/${cdnjs_name}/${version}/${min_cdnjs_file} custom_format: - # Add version number to CDN, true or false - version: false + option: # main_css: # main: diff --git a/package.json b/package.json index 1ac9e18..d2a80b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "4.3.0-b4", + "version": "4.3.0", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/plugins.yml b/plugins.yml index d9043d9..c0d3eae 100644 --- a/plugins.yml +++ b/plugins.yml @@ -5,7 +5,7 @@ algolia_search_v4: instantsearch_v4: name: instantsearch.js file: dist/instantsearch.production.min.js - version: 4.41.2 + version: 4.42.0 pjax: name: pjax file: pjax.min.js @@ -105,7 +105,7 @@ ClickShowText: lazyload: name: vanilla-lazyload file: dist/lazyload.iife.min.js - version: 17.8.2 + version: 17.3.1 instantpage: name: instant.page file: instantpage.js diff --git a/source/css/_page/homepage.styl b/source/css/_page/homepage.styl index cf88f88..9c8153c 100644 --- a/source/css/_page/homepage.styl +++ b/source/css/_page/homepage.styl @@ -82,6 +82,9 @@ i margin: 0 4px 0 0 + .fa-spinner + margin: 0 + .article-meta-label if hexo-config('post_meta.page.label') padding-right: 4px