From 67c013d6e77cd0bde72f7dd4669574b7a73a1bc4 Mon Sep 17 00:00:00 2001 From: Jerry Date: Wed, 18 Mar 2020 18:44:39 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=201.=E4=BF=AE=E5=BE=A9Gitalk=E5=A0=B1Erro?= =?UTF-8?q?r:=20Cannot=20read=20property=20'repository'=20of=20undefined?= =?UTF-8?q?=20=E7=9A=84bug=20:bug:=202.=E4=BF=AE=E5=BE=A9=E8=A9=95?= =?UTF-8?q?=E8=AB=96utterances=20=E5=9C=A8display=5Fmode=E8=A8=AD=E7=BD=AE?= =?UTF-8?q?=E7=82=BAdark=E6=99=82=EF=BC=8C=E4=BB=8D=E9=A1=AF=E7=A4=BAlight?= =?UTF-8?q?=E4=B8=BB=E9=A1=8C=E7=9A=84bug=20:bug:=203.=E4=BF=AE=E5=BE=A9di?= =?UTF-8?q?splay=5Fmode=E8=A8=AD=E7=BD=AEdark=E6=B2=92=E6=9C=89=E6=95=88?= =?UTF-8?q?=E6=9E=9C=E7=9A=84bug=20:art:=204.=E8=A9=95=E8=AB=96=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=A4=9C=E9=96=93=E6=A8=A1=E5=BC=8F=E3=80=81=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E9=A0=81=E5=88=A4=E6=96=B7,=E6=B8=9B=E5=B0=91?= =?UTF-8?q?=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84js=E5=8A=A0=E8=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/includes/comments/disqus.pug | 17 ++++++++------- layout/includes/comments/disqusjs.pug | 17 ++++++++------- layout/includes/comments/gitalk.pug | 8 +++++-- layout/includes/comments/utterances.pug | 28 +++++++++++++------------ source/css/_mode/darkmode.styl | 2 +- 5 files changed, 40 insertions(+), 32 deletions(-) diff --git a/layout/includes/comments/disqus.pug b/layout/includes/comments/disqus.pug index e4c3937..661f53f 100644 --- a/layout/includes/comments/disqus.pug +++ b/layout/includes/comments/disqus.pug @@ -12,12 +12,13 @@ script. (d.head || d.body).appendChild(s); })(); -script. - function getDisqusCount() { - var d = document, s = d.createElement('script'); - s.src = 'https://!{theme.disqus.shortname}.disqus.com/count.js'; - s.id = 'dsq-count-scr'; - (d.head || d.body).appendChild(s); - } +if is_post() && theme.disqus.count + script. + function getDisqusCount() { + var d = document, s = d.createElement('script'); + s.src = 'https://!{theme.disqus.shortname}.disqus.com/count.js'; + s.id = 'dsq-count-scr'; + (d.head || d.body).appendChild(s); + } - window.addEventListener('load', getDisqusCount, false); \ No newline at end of file + window.addEventListener('load', getDisqusCount, false); \ No newline at end of file diff --git a/layout/includes/comments/disqusjs.pug b/layout/includes/comments/disqusjs.pug index 8b9edbe..d1ddd2f 100644 --- a/layout/includes/comments/disqusjs.pug +++ b/layout/includes/comments/disqusjs.pug @@ -13,11 +13,12 @@ script. adminLabel: '!{theme.disqusjs.adminLabel}' }); -script. - function getDisqusCount() { - var d = document, s = d.createElement('script'); - s.src = 'https://!{theme.disqusjs.shortname}.disqus.com/count.js'; - s.id = 'dsq-count-scr'; - (d.head || d.body).appendChild(s); - } - window.addEventListener('load', getDisqusCount, false); +if is_post() && theme.disqusjs.count + script. + function getDisqusCount() { + var d = document, s = d.createElement('script'); + s.src = 'https://!{theme.disqusjs.shortname}.disqus.com/count.js'; + s.id = 'dsq-count-scr'; + (d.head || d.body).appendChild(s); + } + window.addEventListener('load', getDisqusCount, false); diff --git a/layout/includes/comments/gitalk.pug b/layout/includes/comments/gitalk.pug index d4551a2..9a1fee9 100644 --- a/layout/includes/comments/gitalk.pug +++ b/layout/includes/comments/gitalk.pug @@ -8,7 +8,7 @@ script. admin: ['!{theme.gitalk.admin}'], id: md5(decodeURI(location.pathname)), language: '!{theme.gitalk.language}', - perPage: '!{theme.gitalk.perPage}', + perPage: !{theme.gitalk.perPage}, distractionFreeMode: !{theme.gitalk.distractionFreeMode}, pagerDirection: '!{theme.gitalk.pagerDirection}', createIssueManually: !{theme.gitalk.createIssueManually}, @@ -17,7 +17,11 @@ script. gitalk.render('gitalk-container') function commentCount(n){ - document.getElementsByClassName('gitalk-comment-count')[0].innerHTML= n + try { + document.getElementsByClassName('gitalk-comment-count')[0].innerHTML= n + } catch (e) { + return false + } } diff --git a/layout/includes/comments/utterances.pug b/layout/includes/comments/utterances.pug index acb865a..d9cc76d 100644 --- a/layout/includes/comments/utterances.pug +++ b/layout/includes/comments/utterances.pug @@ -1,19 +1,21 @@ script#utterances_comment(src=theme.CDN.utterances repo=theme.utterances.repo issue-term=theme.utterances.issue_term - theme=theme.utterances.light_theme + theme= theme.display_mode === 'dark' ? theme.utterances.dark_theme : theme.utterances.light_theme crossorigin="anonymous" async) -script. - var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}' - document.getElementById('utterances_comment').setAttribute('theme',themeNow) - function utterancesTheme () { - var theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}' - const message = { - type: 'set-theme', - theme: theme - }; - const iframe = document.querySelector('.utterances-frame'); - iframe.contentWindow.postMessage(message, 'https://utteranc.es'); - } +if theme.darkmode.enable + script. + var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}' + document.getElementById('utterances_comment').setAttribute('theme',themeNow) + + function utterancesTheme () { + var theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}' + const message = { + type: 'set-theme', + theme: theme + }; + const iframe = document.querySelector('.utterances-frame'); + iframe.contentWindow.postMessage(message, 'https://utteranc.es'); + } diff --git a/source/css/_mode/darkmode.styl b/source/css/_mode/darkmode.styl index 0730389..ed12656 100644 --- a/source/css/_mode/darkmode.styl +++ b/source/css/_mode/darkmode.styl @@ -1,4 +1,4 @@ -if hexo-config('darkmode.enable') +if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' [data-theme='dark'] body background-color: darken(#121212, 2)