mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2025-09-15 12:58:48 +08:00
🐛 1.修復Gitalk報Error: Cannot read property 'repository' of undefined 的bug
🐛 2.修復評論utterances 在display_mode設置為dark時,仍顯示light主題的bug 🐛 3.修復display_mode設置dark沒有效果的bug 🎨 4.評論增加夜間模式、文章頁判斷,減少不必要的js加載
This commit is contained in:
parent
8bf11ddeb0
commit
67c013d6e7
@ -12,12 +12,13 @@ script.
|
|||||||
(d.head || d.body).appendChild(s);
|
(d.head || d.body).appendChild(s);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
script.
|
if is_post() && theme.disqus.count
|
||||||
function getDisqusCount() {
|
script.
|
||||||
var d = document, s = d.createElement('script');
|
function getDisqusCount() {
|
||||||
s.src = 'https://!{theme.disqus.shortname}.disqus.com/count.js';
|
var d = document, s = d.createElement('script');
|
||||||
s.id = 'dsq-count-scr';
|
s.src = 'https://!{theme.disqus.shortname}.disqus.com/count.js';
|
||||||
(d.head || d.body).appendChild(s);
|
s.id = 'dsq-count-scr';
|
||||||
}
|
(d.head || d.body).appendChild(s);
|
||||||
|
}
|
||||||
|
|
||||||
window.addEventListener('load', getDisqusCount, false);
|
window.addEventListener('load', getDisqusCount, false);
|
||||||
@ -13,11 +13,12 @@ script.
|
|||||||
adminLabel: '!{theme.disqusjs.adminLabel}'
|
adminLabel: '!{theme.disqusjs.adminLabel}'
|
||||||
});
|
});
|
||||||
|
|
||||||
script.
|
if is_post() && theme.disqusjs.count
|
||||||
function getDisqusCount() {
|
script.
|
||||||
var d = document, s = d.createElement('script');
|
function getDisqusCount() {
|
||||||
s.src = 'https://!{theme.disqusjs.shortname}.disqus.com/count.js';
|
var d = document, s = d.createElement('script');
|
||||||
s.id = 'dsq-count-scr';
|
s.src = 'https://!{theme.disqusjs.shortname}.disqus.com/count.js';
|
||||||
(d.head || d.body).appendChild(s);
|
s.id = 'dsq-count-scr';
|
||||||
}
|
(d.head || d.body).appendChild(s);
|
||||||
window.addEventListener('load', getDisqusCount, false);
|
}
|
||||||
|
window.addEventListener('load', getDisqusCount, false);
|
||||||
|
|||||||
@ -8,7 +8,7 @@ script.
|
|||||||
admin: ['!{theme.gitalk.admin}'],
|
admin: ['!{theme.gitalk.admin}'],
|
||||||
id: md5(decodeURI(location.pathname)),
|
id: md5(decodeURI(location.pathname)),
|
||||||
language: '!{theme.gitalk.language}',
|
language: '!{theme.gitalk.language}',
|
||||||
perPage: '!{theme.gitalk.perPage}',
|
perPage: !{theme.gitalk.perPage},
|
||||||
distractionFreeMode: !{theme.gitalk.distractionFreeMode},
|
distractionFreeMode: !{theme.gitalk.distractionFreeMode},
|
||||||
pagerDirection: '!{theme.gitalk.pagerDirection}',
|
pagerDirection: '!{theme.gitalk.pagerDirection}',
|
||||||
createIssueManually: !{theme.gitalk.createIssueManually},
|
createIssueManually: !{theme.gitalk.createIssueManually},
|
||||||
@ -17,7 +17,11 @@ script.
|
|||||||
gitalk.render('gitalk-container')
|
gitalk.render('gitalk-container')
|
||||||
|
|
||||||
function commentCount(n){
|
function commentCount(n){
|
||||||
document.getElementsByClassName('gitalk-comment-count')[0].innerHTML= n
|
try {
|
||||||
|
document.getElementsByClassName('gitalk-comment-count')[0].innerHTML= n
|
||||||
|
} catch (e) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,19 +1,21 @@
|
|||||||
script#utterances_comment(src=theme.CDN.utterances
|
script#utterances_comment(src=theme.CDN.utterances
|
||||||
repo=theme.utterances.repo
|
repo=theme.utterances.repo
|
||||||
issue-term=theme.utterances.issue_term
|
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"
|
crossorigin="anonymous"
|
||||||
async)
|
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 () {
|
if theme.darkmode.enable
|
||||||
var theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
|
script.
|
||||||
const message = {
|
var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
|
||||||
type: 'set-theme',
|
document.getElementById('utterances_comment').setAttribute('theme',themeNow)
|
||||||
theme: theme
|
|
||||||
};
|
function utterancesTheme () {
|
||||||
const iframe = document.querySelector('.utterances-frame');
|
var theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
|
||||||
iframe.contentWindow.postMessage(message, 'https://utteranc.es');
|
const message = {
|
||||||
}
|
type: 'set-theme',
|
||||||
|
theme: theme
|
||||||
|
};
|
||||||
|
const iframe = document.querySelector('.utterances-frame');
|
||||||
|
iframe.contentWindow.postMessage(message, 'https://utteranc.es');
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
if hexo-config('darkmode.enable')
|
if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark'
|
||||||
[data-theme='dark']
|
[data-theme='dark']
|
||||||
body
|
body
|
||||||
background-color: darken(#121212, 2)
|
background-color: darken(#121212, 2)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user