breaking changes: waline 適配 V2

breaking changes: waline 的 visitor 改為 pageview
feat: algolia 搜索增加文章內容顯示和高亮
feat: 搜索內容顯示區域變大
This commit is contained in:
Jerry
2022-05-03 18:57:59 +08:00
parent ec78f66470
commit 5b1473c2c8
21 changed files with 248 additions and 335 deletions

View File

@@ -1,23 +1,35 @@
- const { serverURL, visitor, option } = theme.waline
- 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 = new Waline(Object.assign({
const waline = Waline.init(Object.assign({
el: '#waline-wrap',
serverURL: '!{serverURL}',
path: location.pathname,
visitor: !{visitor},
dark: 'html[data-theme="dark"]'
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 getScript('!{url_for(theme.asset.waline)}').then(initWaline)
else {
insertCSS()
getScript('!{url_for(theme.asset.waline_js)}').then(initWaline)
}
}
if ('!{theme.comments.use[0]}' === 'Waline' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('waline-wrap'),loadWaline)
if ('!{use[0]}' === 'Waline' || !!{lazyload}) {
if (!{lazyload}) btf.loadComment(document.getElementById('waline-wrap'),loadWaline)
else setTimeout(loadWaline, 0)
} else {
function loadOtherComment () {