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,8 +1,6 @@
document.addEventListener('DOMContentLoaded', () => {
NexT.comments.giscus = function() {
const element = '.utterances-container';
if (!NexT.CONFIG.page.comments
|| !NexT.CONFIG.utterances
if (!NexT.CONFIG.utterances
|| !NexT.utils.checkDOMExist(element)) return;
const {
@@ -11,17 +9,19 @@ document.addEventListener('DOMContentLoaded', () => {
label,
theme } = NexT.CONFIG.utterances.cfg;
NexT.utils.loadComments(element)
.then(() => NexT.utils.getScript(NexT.CONFIG.utterances.js, {
NexT.utils.lazyLoadComponent(element, function() {
NexT.utils.getScript(NexT.CONFIG.utterances.js, {
attributes: {
'async' : true,
'crossorigin' : 'anonymous',
'repo' : repo,
'issue-term' : issueterm,
'label' : label,
'theme' : theme
},
parentNode: document.querySelector(element)
}));
});
NexT.utils.hiddeLodingCmp(element);
});
});
}