🏗️ First time sync the css & js files from hexo theme NexT
This commit is contained in:
41
assets/js/third-party/comments/disqus.js
vendored
Normal file
41
assets/js/third-party/comments/disqus.js
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/* global NexT, CONFIG, DISQUS */
|
||||
|
||||
document.addEventListener('page:loaded', () => {
|
||||
|
||||
if (CONFIG.disqus.count) {
|
||||
const loadCount = () => {
|
||||
NexT.utils.getScript(`https://${CONFIG.disqus.shortname}.disqus.com/count.js`, {
|
||||
attributes: { id: 'dsq-count-scr' }
|
||||
});
|
||||
};
|
||||
|
||||
// defer loading until the whole page loading is completed
|
||||
window.addEventListener('load', loadCount, false);
|
||||
}
|
||||
|
||||
if (CONFIG.page.comments) {
|
||||
// `disqus_config` should be a global variable
|
||||
// See https://help.disqus.com/en/articles/1717084-javascript-configuration-variables
|
||||
window.disqus_config = function() {
|
||||
this.page.url = CONFIG.page.permalink;
|
||||
this.page.identifier = CONFIG.page.path;
|
||||
this.page.title = CONFIG.page.title;
|
||||
if (CONFIG.disqus.i18n.disqus !== 'disqus') {
|
||||
this.language = CONFIG.disqus.i18n.disqus;
|
||||
}
|
||||
};
|
||||
NexT.utils.loadComments('#disqus_thread').then(() => {
|
||||
if (window.DISQUS) {
|
||||
DISQUS.reset({
|
||||
reload: true,
|
||||
config: window.disqus_config
|
||||
});
|
||||
} else {
|
||||
NexT.utils.getScript(`https://${CONFIG.disqus.shortname}.disqus.com/embed.js`, {
|
||||
attributes: { dataset: { timestamp: '' + +new Date() } }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user