hexo-theme-stellar/layout/_partial/comments/twikoo/script.ejs

15 lines
549 B
Plaintext
Raw Normal View History

2024-05-31 20:32:04 +08:00
<script type="module">
const el = document.getElementById('twikoo_container');
2024-05-31 20:32:04 +08:00
util.viewportLazyload(el, load_twikoo, <%= theme.comments.lazyload ?? false %>);
2024-05-31 20:32:04 +08:00
function load_twikoo() {
if (!el) return;
utils.js('<%- theme.comments.twikoo.js %>', {defer: true}).then(function () {
const path = el.getAttribute('comment_id') ?? decodeURI(window.location.pathname);
2024-05-31 20:32:04 +08:00
twikoo.init(Object.assign(<%- JSON.stringify(theme.comments.twikoo) %>, {
el: '#twikoo_container',
path: path,
}));
});
2024-05-31 20:32:04 +08:00
}
</script>