23 lines
666 B
Plaintext
23 lines
666 B
Plaintext
<script type="module">
|
|
const el = document.querySelector('#comments #giscus');
|
|
util.viewportLazyload(el, load_discus, <%= theme.comments.lazyload ?? false %>);
|
|
|
|
function load_discus() {
|
|
if (!el) return;
|
|
try {
|
|
el.innerHTML = '';
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
const script = document.createElement('script');
|
|
script.async = true;
|
|
for (const key of Object.keys(el.attributes)) {
|
|
const attr = el.attributes[key];
|
|
if (['class', 'id'].includes(attr.name) === false) {
|
|
script.setAttribute(attr.name, attr.value);
|
|
}
|
|
}
|
|
el.appendChild(script);
|
|
}
|
|
</script>
|