feat: gitalk 增加 option 配置

improvement: pug代碼優化
This commit is contained in:
Jerry
2021-02-20 23:10:28 +08:00
parent b176ff0fa7
commit 41e1931a3a
5 changed files with 11 additions and 38 deletions

View File

@@ -8,7 +8,7 @@ script.
function loadGitalk () { function loadGitalk () {
function initGitalk () { function initGitalk () {
var gitalk = new Gitalk({ var gitalk = new Gitalk(Object.assign({
clientID: '!{theme.gitalk.client_id}', clientID: '!{theme.gitalk.client_id}',
clientSecret: '!{theme.gitalk.client_secret}', clientSecret: '!{theme.gitalk.client_secret}',
repo: '!{theme.gitalk.repo}', repo: '!{theme.gitalk.repo}',
@@ -21,7 +21,8 @@ script.
pagerDirection: '!{theme.gitalk.pagerDirection}', pagerDirection: '!{theme.gitalk.pagerDirection}',
createIssueManually: !{theme.gitalk.createIssueManually}, createIssueManually: !{theme.gitalk.createIssueManually},
updateCountCallback: commentCount updateCountCallback: commentCount
}) },!{JSON.stringify(theme.gitalk.option)}))
gitalk.render('gitalk-container') gitalk.render('gitalk-container')
} }

View File

@@ -1,21 +1,12 @@
- let option = theme.twikoo.option ? JSON.stringify(theme.twikoo.option) : false
script. script.
(()=>{ (()=>{
const $countDom = document.getElementById('twikoo-count') const $countDom = document.getElementById('twikoo-count')
const init = () => { const init = () => {
let initData = { twikoo.init(Object.assign({
el: '#twikoo-wrap', el: '#twikoo-wrap',
envId: '!{theme.twikoo.envId}', envId: '!{theme.twikoo.envId}',
region: '!{theme.twikoo.region}' region: '!{theme.twikoo.region}'
} }, !{JSON.stringify(theme.twikoo.option)}))
if (!{Boolean(option)}) {
const otherData = !{option}
initData = Object.assign(initData, otherData)
}
twikoo.init(initData)
} }
const getCount = () => { const getCount = () => {

View File

@@ -1,4 +1,3 @@
- let option = theme.valine.option ? JSON.stringify(theme.valine.option) : false
- let emojiMaps = '""' - let emojiMaps = '""'
if site.data.valine if site.data.valine
- emojiMaps = JSON.stringify(site.data.valine) - emojiMaps = JSON.stringify(site.data.valine)
@@ -6,7 +5,7 @@ if site.data.valine
script. script.
function loadValine () { function loadValine () {
function initValine () { function initValine () {
let initData = { const valine = new Valine(Object.assign({
el: '#vcomment', el: '#vcomment',
appId: '#{theme.valine.appId}', appId: '#{theme.valine.appId}',
appKey: '#{theme.valine.appKey}', appKey: '#{theme.valine.appKey}',
@@ -21,19 +20,9 @@ script.
emojiMaps: !{emojiMaps}, emojiMaps: !{emojiMaps},
enableQQ: #{theme.valine.enableQQ}, enableQQ: #{theme.valine.enableQQ},
path: window.location.pathname, path: window.location.pathname,
requiredFields: [!{theme.valine.requiredFields ? JSON.stringify(theme.valine.requiredFields).split(',') : ''}],
visitor: #{theme.valine.visitor} visitor: #{theme.valine.visitor}
} }, !{JSON.stringify(theme.valine.option)}))
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)
} }
if (typeof Valine === 'function') initValine() if (typeof Valine === 'function') initValine()

View File

@@ -1,4 +1,3 @@
- let option = theme.waline.option ? JSON.stringify(theme.waline.option) : false
- let emojiMaps = '""' - let emojiMaps = '""'
if site.data.waline if site.data.waline
- emojiMaps = JSON.stringify(site.data.waline) - emojiMaps = JSON.stringify(site.data.waline)
@@ -6,7 +5,7 @@ if site.data.waline
script. script.
function loadWaline () { function loadWaline () {
function initWaline () { function initWaline () {
let initData = { const waline = new Waline(Object.assign({
el: '#waline-wrap', el: '#waline-wrap',
serverURL: '!{theme.waline.serverURL}', serverURL: '!{theme.waline.serverURL}',
avatar: '#{theme.waline.avatar}', avatar: '#{theme.waline.avatar}',
@@ -14,14 +13,7 @@ script.
emojiCDN: '#{theme.waline.emojiCDN}', emojiCDN: '#{theme.waline.emojiCDN}',
emojiMaps: !{emojiMaps}, emojiMaps: !{emojiMaps},
visitor: #{theme.waline.visitor} visitor: #{theme.waline.visitor}
} }, !{JSON.stringify(theme.waline.option)}))
if (!{Boolean(option)}) {
const otherData = !{option}
initData = Object.assign(initData, otherData)
}
const waline = new Waline(initData)
} }
if (typeof Waline === 'function') initWaline() if (typeof Waline === 'function') initWaline()

View File

@@ -1,6 +1,6 @@
{ {
"name": "hexo-theme-butterfly", "name": "hexo-theme-butterfly",
"version": "3.7.0-b3", "version": "3.7.0-b4",
"description": "A Simple and Card UI Design theme for Hexo", "description": "A Simple and Card UI Design theme for Hexo",
"main": "package.json", "main": "package.json",
"scripts": { "scripts": {