⚡ Improved the comments plug-in load function, close #12
This commit is contained in:
23
assets/js/third-party/comments/livere.js
vendored
23
assets/js/third-party/comments/livere.js
vendored
@@ -1,19 +1,18 @@
|
||||
/* global NexT, CONFIG, LivereTower */
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
document.addEventListener('page:loaded', () => {
|
||||
if (!CONFIG.page.comments) return;
|
||||
const element = '#lv-container';
|
||||
if (!NexT.CONFIG.comments.enable
|
||||
|| !NexT.CONFIG.livere
|
||||
|| !NexT.utils.checkDOMExist(element)) return;
|
||||
|
||||
NexT.utils.loadComments('#lv-container').then(() => {
|
||||
window.livereOptions = {
|
||||
refer: CONFIG.page.path.replace(/index\.html$/, '')
|
||||
};
|
||||
|
||||
if (typeof LivereTower === 'function') return;
|
||||
|
||||
NexT.utils.getScript('https://cdn-city.livere.com/js/embed.dist.js', {
|
||||
NexT.utils.loadComments(element).then(() => {
|
||||
NexT.utils.getScript(NexT.CONFIG.livere.js, {
|
||||
attributes: {
|
||||
async: true
|
||||
}
|
||||
},
|
||||
parentNode: document.querySelector(element)
|
||||
});
|
||||
|
||||
NexT.utils.hiddeLodingCmp(element);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user