Refactoring the comments component js scripts.

This commit is contained in:
凡梦星尘
2022-10-24 22:08:17 +08:00
parent b9511728f3
commit 90df1e1247
9 changed files with 79 additions and 80 deletions

View File

@@ -1,5 +1,4 @@
document.addEventListener('DOMContentLoaded', () => {
NexT.comments.giscus = function() {
const element = '.giscus-container';
if (!NexT.CONFIG.page.comments
|| !NexT.CONFIG.giscus
@@ -17,8 +16,8 @@ document.addEventListener('DOMContentLoaded', () => {
theme } = NexT.CONFIG.giscus.cfg;
NexT.utils.loadComments(element)
.then(() => NexT.utils.getScript(NexT.CONFIG.giscus.js, {
NexT.utils.lazyLoadComponent(element, function() {
NexT.utils.getScript(NexT.CONFIG.giscus.js, {
attributes: {
'async' : true,
'crossorigin' : 'anonymous',
@@ -35,7 +34,8 @@ document.addEventListener('DOMContentLoaded', () => {
'data-loading' : 'lazy'
},
parentNode: document.querySelector(element)
}));
});
NexT.utils.hiddeLodingCmp(element);
});
});
}