disqus/disqusjs/facebook comments 可隨夜間模式按鈕切換而轉換主題

🐛 修復pjax下valine評論顯示不正常的bugs
🐛 修復facebook comments 在手機下寬度不是100%的bugs
This commit is contained in:
Jerry
2020-07-18 22:30:15 +08:00
parent f7d57ac883
commit 4f64768011
17 changed files with 120 additions and 98 deletions

View File

@@ -13,6 +13,18 @@ script.
document.getElementById('utterances-wrap').insertAdjacentElement('afterbegin',ele)
}
function utterancesTheme () {
if (document.querySelector('.utterances-frame')) {
const 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 ('!{defaultComment}' === 'Utterances' || !{theme.comments.load_begin}) {
loadUtterances()
}
@@ -21,16 +33,4 @@ script.
loadUtterances()
}
}
}
if theme.darkmode.enable
script.
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');
}
}