- const { server, site, option } = theme.artalk script. function loadArtalk () { function initArtalk () { window.artalkItem = new Artalk(Object.assign({ el: '#artalk-wrap', server: '!{server}', site: '!{site}', pageKey: location.pathname, darkMode: document.documentElement.getAttribute('data-theme') === 'dark', countEl: '.artalk-count' },!{JSON.stringify(option)})) if (GLOBAL_CONFIG.lightbox === 'null') return window.artalkItem.use(ctx => { ctx.on('list-loaded', () => { ctx.getCommentList().forEach(comment => { const $content = comment.getRender().$content btf.loadLightbox($content.querySelectorAll('img:not([atk-emoticon])')) }) }) }) } if (typeof window.artalkItem === 'object') initArtalk() else { getCSS('!{theme.asset.artalk_css}').then(()=>{ getScript('!{theme.asset.artalk_js}').then(initArtalk) }) } } function artalkChangeMode (theme) { const artalkWrap = document.getElementById('artalk-wrap') if (!(artalkWrap && artalkWrap.children.length)) return const isDark = theme === 'dark' window.artalkItem.setDarkMode(isDark) } btf.addModeChange('artalk', artalkChangeMode) if ('!{theme.comments.use[0]}' === 'Artalk' || !!{theme.comments.lazyload}) { if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('artalk-wrap'), loadArtalk) else loadArtalk() } else { function loadOtherComment () { loadArtalk() } }