hexo-theme-butterfly/layout/includes/third-party/comments/disqusjs.pug
Jerry 507453671a 🐛 適配hexo 5.0.0 修復toc點擊不會跳轉的bugs
🐛 適配hexo 5.0.0 修復toc點擊不會跳轉的bugs
🍻 文件整理
🍻 UI微調
2020-08-01 01:50:01 +08:00

58 lines
1.7 KiB
Plaintext

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({
shortname: '!{theme.disqusjs.shortname}',
siteName: '!{theme.disqusjs.siteName}',
identifier: '!{ page.path }',
url: '!{ page.permalink }',
title: '!{ page.title }',
api: '!{theme.disqusjs.api}',
apikey: '!{theme.disqusjs.apikey}',
nocomment: '!{theme.disqusjs.nocomment}',
admin: '!{theme.disqusjs.admin}',
adminLabel: '!{theme.disqusjs.adminLabel}'
});
}
window.disqusReset = initDisqusjs
if (window.disqusJsLoad) initDisqusjs()
else {
addDisqusjsCSS()
$.getScript('!{url_for(theme.CDN.disqusjs)}', initDisqusjs)
window.disqusJsLoad = true
}
}
if ('!{theme.comments.use[0]}' === 'Disqusjs' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) 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});
}