mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
breaking changes: waline 適配 V2
breaking changes: waline 的 visitor 改為 pageview feat: algolia 搜索增加文章內容顯示和高亮 feat: 搜索內容顯示區域變大
This commit is contained in:
28
layout/includes/third-party/comments/waline.pug
vendored
28
layout/includes/third-party/comments/waline.pug
vendored
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user