<% if(theme.comment.waline.serverUrl
        && theme.comment.waline.lang
        && (!page.hasOwnProperty('comment'))
        || (page.hasOwnProperty('comment') && page.comment)
) { %>

    <div id="waline"></div>
    <script type="module"  >
        import { init } from 'https://npm.elemecdn.com/hexo-theme-a4@latest/source/js/waline.mjs'; 
        function loadWaline() {
            init({
                el: '#waline',
                serverURL: '<%= theme.comment.waline.serverUrl %>',
                lang: '<%= theme.comment.waline.lang %>',
                dark: 'body[class~="dark-mode"]',
                requiredMeta: ['nick','mail'], // cannot customize by theme config, change it yourself
                search: false, // 禁止表情包搜索
                reaction: false, // 对文章打分
                pageview: false, // 浏览量统计
                comment: false, // 评论数统计

                locale: {
                    placeholder: '<%= theme.comment.waline.placeholder %>', 
                    sofa: ''
                },
            });
            
        }
        window.addEventListener('DOMContentLoaded', loadWaline);
    </script>

<% } %>
