hexo-theme-butterfly/layout/includes/comments/utterances.pug
Jerry 67c013d6e7 🐛 1.修復Gitalk報Error: Cannot read property 'repository' of undefined 的bug
🐛 2.修復評論utterances 在display_mode設置為dark時,仍顯示light主題的bug
🐛 3.修復display_mode設置dark沒有效果的bug
🎨 4.評論增加夜間模式、文章頁判斷,減少不必要的js加載
2020-03-18 18:44:39 +08:00

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');
}