41 lines
1.1 KiB
Plaintext
41 lines
1.1 KiB
Plaintext
- const { serverURL, option, pageview } = theme.waline
|
|
- const { lazyload, count, use } = theme.comments
|
|
|
|
script.
|
|
function loadWaline () {
|
|
function insertCSS () {
|
|
const link = document.createElement("link")
|
|
link.rel = "stylesheet"
|
|
link.href = "!{url_for(theme.asset.waline_css)}"
|
|
document.head.appendChild(link)
|
|
}
|
|
|
|
function initWaline () {
|
|
const waline = Waline.init(Object.assign({
|
|
el: '#waline-wrap',
|
|
serverURL: '!{serverURL}',
|
|
pageview: !{lazyload ? false : pageview},
|
|
dark: 'html[data-theme="dark"]',
|
|
path: window.location.pathname,
|
|
comment: !{lazyload ? false : count},
|
|
}, !{JSON.stringify(option)}))
|
|
}
|
|
|
|
if (typeof Waline === 'function') initWaline()
|
|
else {
|
|
insertCSS()
|
|
getScript('!{url_for(theme.asset.waline_js)}').then(initWaline)
|
|
}
|
|
}
|
|
|
|
if ('!{use[0]}' === 'Waline' || !!{lazyload}) {
|
|
if (!{lazyload}) btf.loadComment(document.getElementById('waline-wrap'),loadWaline)
|
|
else setTimeout(loadWaline, 0)
|
|
} else {
|
|
function loadOtherComment () {
|
|
loadWaline()
|
|
}
|
|
}
|
|
|
|
|