- const { server, site, option } = theme.artalk script. function addArtalkSource () { const ele = document.createElement('link') ele.rel = 'stylesheet' ele.href= '!{theme.asset.artalk_css}' document.getElementsByTagName('head')[0].appendChild(ele) } 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 (typeof window.artalkItem === 'object') setTimeout(()=>{initArtalk()},200) else { addArtalkSource() typeof Artalk !== 'function' ? getScript('!{theme.asset.artalk_js}').then(initArtalk) : setTimeout(()=>{initArtalk()},200) } } document.getElementById('darkmode').addEventListener('click',()=> { if (typeof window.artalkItem !== 'object') return let isDark = document.documentElement.getAttribute('data-theme') === 'dark' window.artalkItem.setDarkMode(!isDark) }) 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() } }