⚡ Refactoring the comments component js scripts.
This commit is contained in:
24
assets/js/third-party/comments/artalk.js
vendored
24
assets/js/third-party/comments/artalk.js
vendored
@@ -1,13 +1,8 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
NexT.comments.giscus = function() {
|
||||
const element = '.artalk-container';
|
||||
if (!NexT.CONFIG.page.comments
|
||||
|| !NexT.CONFIG.artalk
|
||||
if (!NexT.CONFIG.artalk
|
||||
|| !NexT.utils.checkDOMExist(element)) return;
|
||||
|
||||
const artalk_css = NexT.utils.getCDNResource(NexT.CONFIG.artalk.css);
|
||||
NexT.utils.getStyle(artalk_css, null);
|
||||
|
||||
const artalk_js = NexT.utils.getCDNResource(NexT.CONFIG.artalk.js);
|
||||
const {
|
||||
site,
|
||||
@@ -15,10 +10,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
server,
|
||||
} = NexT.CONFIG.artalk.cfg;
|
||||
|
||||
NexT.utils.loadComments(element)
|
||||
.then(() => NexT.utils.getScript(artalk_js, {
|
||||
}))
|
||||
.then(() => {
|
||||
NexT.utils.lazyLoadComponent(element, function() {
|
||||
NexT.utils.getScript(artalk_js, function(){
|
||||
const artalk_css = NexT.utils.getCDNResource(NexT.CONFIG.artalk.css);
|
||||
NexT.utils.getStyle(artalk_css);
|
||||
|
||||
new Artalk({
|
||||
el : element,
|
||||
@@ -29,8 +24,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
locale : NexT.CONFIG.lang,
|
||||
placeholder : placeholder,
|
||||
darkMode : 'auto'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
NexT.utils.hiddeLodingCmp(element);
|
||||
NexT.utils.hiddeLodingCmp(element);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user