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)