mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2025-09-15 12:58:48 +08:00
feat: 設置了隨系統而切換淺色和深色模式後,評論和 mermaind 也會跟隨切換顏色 feat: artalk 最新評論,從 artalk 配置讀取頭像 CDN 和默認頭像 fix: 修復代碼塊在未展開時,點擊複製按鈕,無法複製的 bug improvement: 代碼和性能優化 improvement: artalk 獲取評論數,由 LoadCountWidget 改為 loadCountWidget
50 lines
1.4 KiB
Plaintext
50 lines
1.4 KiB
Plaintext
- let disqusPageTitle = page.title.replace(/'/ig,"\\'")
|
|
|
|
script.
|
|
function loadDisqus () {
|
|
const disqus_config = function () {
|
|
this.page.url = '!{ page.permalink }'
|
|
this.page.identifier = '!{ url_for(page.path) }'
|
|
this.page.title = '!{ disqusPageTitle }'
|
|
}
|
|
|
|
const disqusReset = () => {
|
|
DISQUS.reset({
|
|
reload: true,
|
|
config: disqus_config
|
|
})
|
|
}
|
|
|
|
btf.addModeChange('disqus', disqusReset)
|
|
|
|
if (window.DISQUS) disqusReset()
|
|
else {
|
|
(function() {
|
|
var d = document, s = d.createElement('script');
|
|
s.src = 'https://!{theme.disqus.shortname}.disqus.com/embed.js';
|
|
s.setAttribute('data-timestamp', +new Date());
|
|
(d.head || d.body).appendChild(s);
|
|
})();
|
|
}
|
|
}
|
|
|
|
if ('!{theme.comments.use[0]}' === 'Disqus' || !!{theme.comments.lazyload}) {
|
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('disqus_thread'), loadDisqus)
|
|
else loadDisqus()
|
|
} else {
|
|
function loadOtherComment () {
|
|
loadDisqus()
|
|
}
|
|
}
|
|
|
|
if is_post() && !theme.comments.lazyload && theme.comments.count && theme.comments.use[0] === 'Disqus'
|
|
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});
|
|
}
|