mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 22:17:06 +08:00
feat: gitalk 增加 option 配置
improvement: pug代碼優化
This commit is contained in:
17
layout/includes/third-party/comments/valine.pug
vendored
17
layout/includes/third-party/comments/valine.pug
vendored
@@ -1,4 +1,3 @@
|
||||
- let option = theme.valine.option ? JSON.stringify(theme.valine.option) : false
|
||||
- let emojiMaps = '""'
|
||||
if site.data.valine
|
||||
- emojiMaps = JSON.stringify(site.data.valine)
|
||||
@@ -6,7 +5,7 @@ if site.data.valine
|
||||
script.
|
||||
function loadValine () {
|
||||
function initValine () {
|
||||
let initData = {
|
||||
const valine = new Valine(Object.assign({
|
||||
el: '#vcomment',
|
||||
appId: '#{theme.valine.appId}',
|
||||
appKey: '#{theme.valine.appKey}',
|
||||
@@ -21,19 +20,9 @@ script.
|
||||
emojiMaps: !{emojiMaps},
|
||||
enableQQ: #{theme.valine.enableQQ},
|
||||
path: window.location.pathname,
|
||||
requiredFields: [!{theme.valine.requiredFields ? JSON.stringify(theme.valine.requiredFields).split(',') : ''}],
|
||||
visitor: #{theme.valine.visitor}
|
||||
}
|
||||
|
||||
if (!{Boolean(theme.valine.requiredFields)}) {
|
||||
initData.requiredFields= ('!{theme.valine.requiredFields}'.split(','))
|
||||
}
|
||||
|
||||
if (!{Boolean(option)}) {
|
||||
const otherData = !{option}
|
||||
initData = Object.assign(initData, otherData)
|
||||
}
|
||||
|
||||
const valine = new Valine(initData)
|
||||
}, !{JSON.stringify(theme.valine.option)}))
|
||||
}
|
||||
|
||||
if (typeof Valine === 'function') initValine()
|
||||
|
||||
Reference in New Issue
Block a user