⚡ Refactoring the comments component js scripts.
This commit is contained in:
16
assets/js/third-party/comments/utterances.js
vendored
16
assets/js/third-party/comments/utterances.js
vendored
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user