mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2025-09-15 12:58:48 +08:00
feat: sidebar menu 點擊展開不再限制只能點擊按鈕 #640 feat: TWIKOO 評論圖片添加 lightbox feat: 升級 facebook comment js 到 v11 fix: 修復可能導致相關文章鏈接出錯的bug #549 improvement: 調整代碼框 ocean theme 下滾動條顏色 close #651 improvement: 當圖片沒有 figcaption 時,不會添加 figcaption 代碼 improvement: 代碼優化
35 lines
1.4 KiB
Plaintext
35 lines
1.4 KiB
Plaintext
script.
|
|
function loadUtterances () {
|
|
let ele = document.createElement('script')
|
|
ele.setAttribute('id', 'utterances_comment')
|
|
ele.setAttribute('src', '!{url_for(theme.CDN.utterances)}')
|
|
ele.setAttribute('repo', '!{theme.utterances.repo}')
|
|
ele.setAttribute('issue-term', '!{theme.utterances.issue_term}')
|
|
let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
|
|
ele.setAttribute('theme', nowTheme)
|
|
ele.setAttribute('crossorigin', 'anonymous')
|
|
ele.setAttribute('async', 'true')
|
|
document.getElementById('utterances-wrap').insertAdjacentElement('afterbegin',ele)
|
|
}
|
|
|
|
function utterancesTheme () {
|
|
const iframe = document.querySelector('.utterances-frame')
|
|
if (iframe) {
|
|
const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
|
|
const message = {
|
|
type: 'set-theme',
|
|
theme: theme
|
|
};
|
|
iframe.contentWindow.postMessage(message, 'https://utteranc.es');
|
|
}
|
|
}
|
|
|
|
if ('!{theme.comments.use[0]}' === 'Utterances' || !!{theme.comments.lazyload}) {
|
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('utterances-wrap'), loadUtterances)
|
|
else loadUtterances()
|
|
} else {
|
|
function loadOtherComment () {
|
|
loadUtterances()
|
|
}
|
|
}
|