hexo-theme-stellar/layout/_partial/plugins/comments/artalk/script.ejs

25 lines
904 B
Plaintext

<script>
function load_artalk() {
if (!document.querySelectorAll("#artalk_container")[0]) return;
stellar.loadCSS('<%- theme.comments.artalk.css %>');
stellar.loadScript('<%- theme.comments.artalk.js %>', {defer: true}).then(function () {
const el = document.getElementById("artalk_container");
var path = el.getAttribute('comment_id');
if (!path) {
path = decodeURI(window.location.pathname);
}
var artalk = Artalk.init({
el: '#artalk_container',
pageKey: path,
pageTitle: '<%= page.title %>',
server: '<%= theme.comments.artalk.server %>',
placeholder: '<%= theme.comments.artalk.placeholder %>',
site: '<%= config.title %>',
darkMode: '<%= theme.comments.artalk.darkMode %>'
})
});
}
window.addEventListener('DOMContentLoaded', (event) => {
load_artalk();
});
</script>