<script>
    function load_twikoo() {
        if (!document.querySelectorAll("#twikoo_container")[0]) return;
        stellar.loadScript('<%- theme.comments.twikoo.js %>', {defer: true}).then(function () {
            const el = document.getElementById("twikoo_container");
            var path = el.getAttribute('comment_id');
            if (!path) {
                path = decodeURI(window.location.pathname);
            }
            twikoo.init(Object.assign(<%- JSON.stringify(theme.comments.twikoo) %>, {
                el: '#twikoo_container',
                path: path,
            }));
        });
    }

    window.addEventListener('DOMContentLoaded', (event) => {
        load_twikoo();
    });
</script>