mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2025-09-15 12:58:48 +08:00
🐛 2.修復評論utterances 在display_mode設置為dark時,仍顯示light主題的bug 🐛 3.修復display_mode設置dark沒有效果的bug 🎨 4.評論增加夜間模式、文章頁判斷,減少不必要的js加載
22 lines
954 B
Plaintext
22 lines
954 B
Plaintext
script#utterances_comment(src=theme.CDN.utterances
|
|
repo=theme.utterances.repo
|
|
issue-term=theme.utterances.issue_term
|
|
theme= theme.display_mode === 'dark' ? theme.utterances.dark_theme : theme.utterances.light_theme
|
|
crossorigin="anonymous"
|
|
async)
|
|
|
|
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');
|
|
}
|