mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-17 04:40:53 +08:00
56 lines
1.6 KiB
Plaintext
56 lines
1.6 KiB
Plaintext
- let disqusjsPageTitle = page.title.replace(/'/ig,"\\'")
|
|
|
|
script.
|
|
function loadDisqusjs () {
|
|
function addDisqusjsCSS () {
|
|
const ele = document.createElement('link')
|
|
ele.rel = 'stylesheet'
|
|
ele.href= '!{url_for(theme.CDN.disqusjs_css)}'
|
|
document.getElementsByTagName('head')[0].appendChild(ele)
|
|
}
|
|
|
|
function initDisqusjs () {
|
|
window.DISQUS = null
|
|
new DisqusJS(Object.assign({
|
|
shortname: '!{theme.disqusjs.shortname}',
|
|
identifier: '!{ page.path }',
|
|
url: '!{ page.permalink }',
|
|
title: '!{ disqusjsPageTitle }',
|
|
apikey: '!{theme.disqusjs.apikey}',
|
|
},!{JSON.stringify(theme.disqusjs.option)}))
|
|
}
|
|
|
|
|
|
window.disqusReset = initDisqusjs
|
|
|
|
if (window.disqusJsLoad) initDisqusjs()
|
|
else {
|
|
addDisqusjsCSS()
|
|
getScript('!{url_for(theme.CDN.disqusjs)}').then(initDisqusjs)
|
|
window.disqusJsLoad = true
|
|
}
|
|
}
|
|
|
|
if ('!{theme.comments.use[0]}' === 'Disqusjs' || !!{theme.comments.lazyload}) {
|
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('disqus_thread'), loadDisqusjs)
|
|
else loadDisqusjs()
|
|
}
|
|
else {
|
|
function loadOtherComment () {
|
|
loadDisqusjs()
|
|
}
|
|
}
|
|
|
|
|
|
if is_post() && !theme.comments.lazyload && theme.comments.count && theme.comments.use[0] === 'Disqusjs'
|
|
script.
|
|
if (window.DISQUSWIDGETS === undefined) {
|
|
var d = document, s = d.createElement('script');
|
|
s.src = 'https://!{theme.disqus.shortname}.disqus.com/count.js';
|
|
s.id = 'dsq-count-scr';
|
|
(d.head || d.body).appendChild(s);
|
|
} else {
|
|
DISQUSWIDGETS.getCount({reset: true});
|
|
}
|
|
|