mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2025-09-15 12:58:48 +08:00
43 lines
1.5 KiB
Plaintext
43 lines
1.5 KiB
Plaintext
- const { host, siteId, language, option } = theme.remark42
|
|
script.
|
|
let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
|
|
var remark_config = Object.assign({
|
|
host: '!{host}',
|
|
site_id: '!{siteId}',
|
|
components: ['embed'],
|
|
locale: '!{language}',
|
|
},!{JSON.stringify(option)})
|
|
|
|
script.
|
|
function loadRemark42(){
|
|
!(function (e, n) {
|
|
for (var o = 0; o < e.length; o++) {
|
|
var r = n.createElement('script'),
|
|
c = '.js',
|
|
d = n.head || n.body
|
|
'noModule' in r ? ((r.type = 'module'), (c = '.mjs')) : (r.async = !0),
|
|
(r.defer = !0),
|
|
(r.src = remark_config.host + '/web/' + e[o] + c),
|
|
d.appendChild(r)
|
|
}
|
|
})(remark_config.components || ['embed'], document)
|
|
}
|
|
|
|
function changeRemark42Theme(){
|
|
let theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark'
|
|
window.REMARK42.changeTheme(theme)
|
|
}
|
|
|
|
let themeBtn = document.getElementById('darkmode')
|
|
themeBtn.addEventListener('click',()=>{
|
|
changeRemark42Theme()
|
|
})
|
|
|
|
if ('!{theme.comments.use[0]}' === 'Remark42' || !!{theme.comments.lazyload}) {
|
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('remark42'), loadRemark42)
|
|
else loadRemark42()
|
|
} else {
|
|
function loadOtherComment () {
|
|
loadRemark42()
|
|
}
|
|
} |