From 41e1931a3a28e5404f0e3dce400c67ab4af4bb20 Mon Sep 17 00:00:00 2001 From: Jerry Date: Sat, 20 Feb 2021 23:10:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20gitalk=20=E5=A2=9E=E5=8A=A0=20option=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=20improvement:=20pug=E4=BB=A3=E7=A2=BC?= =?UTF-8?q?=E5=84=AA=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/includes/third-party/comments/gitalk.pug | 5 +++-- layout/includes/third-party/comments/twikoo.pug | 13 ++----------- layout/includes/third-party/comments/valine.pug | 17 +++-------------- layout/includes/third-party/comments/waline.pug | 12 ++---------- package.json | 2 +- 5 files changed, 11 insertions(+), 38 deletions(-) diff --git a/layout/includes/third-party/comments/gitalk.pug b/layout/includes/third-party/comments/gitalk.pug index dcd6eb6..8e78386 100644 --- a/layout/includes/third-party/comments/gitalk.pug +++ b/layout/includes/third-party/comments/gitalk.pug @@ -8,7 +8,7 @@ script. function loadGitalk () { function initGitalk () { - var gitalk = new Gitalk({ + var gitalk = new Gitalk(Object.assign({ clientID: '!{theme.gitalk.client_id}', clientSecret: '!{theme.gitalk.client_secret}', repo: '!{theme.gitalk.repo}', @@ -21,7 +21,8 @@ script. pagerDirection: '!{theme.gitalk.pagerDirection}', createIssueManually: !{theme.gitalk.createIssueManually}, updateCountCallback: commentCount - }) + },!{JSON.stringify(theme.gitalk.option)})) + gitalk.render('gitalk-container') } diff --git a/layout/includes/third-party/comments/twikoo.pug b/layout/includes/third-party/comments/twikoo.pug index d47a5d5..8fcf32f 100644 --- a/layout/includes/third-party/comments/twikoo.pug +++ b/layout/includes/third-party/comments/twikoo.pug @@ -1,21 +1,12 @@ -- let option = theme.twikoo.option ? JSON.stringify(theme.twikoo.option) : false - script. (()=>{ const $countDom = document.getElementById('twikoo-count') const init = () => { - let initData = { + twikoo.init(Object.assign({ el: '#twikoo-wrap', envId: '!{theme.twikoo.envId}', region: '!{theme.twikoo.region}' - } - - if (!{Boolean(option)}) { - const otherData = !{option} - initData = Object.assign(initData, otherData) - } - - twikoo.init(initData) + }, !{JSON.stringify(theme.twikoo.option)})) } const getCount = () => { diff --git a/layout/includes/third-party/comments/valine.pug b/layout/includes/third-party/comments/valine.pug index 249a4e3..d5121bc 100644 --- a/layout/includes/third-party/comments/valine.pug +++ b/layout/includes/third-party/comments/valine.pug @@ -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() diff --git a/layout/includes/third-party/comments/waline.pug b/layout/includes/third-party/comments/waline.pug index b1d3eb1..9588049 100644 --- a/layout/includes/third-party/comments/waline.pug +++ b/layout/includes/third-party/comments/waline.pug @@ -1,4 +1,3 @@ -- let option = theme.waline.option ? JSON.stringify(theme.waline.option) : false - let emojiMaps = '""' if site.data.waline - emojiMaps = JSON.stringify(site.data.waline) @@ -6,7 +5,7 @@ if site.data.waline script. function loadWaline () { function initWaline () { - let initData = { + const waline = new Waline(Object.assign({ el: '#waline-wrap', serverURL: '!{theme.waline.serverURL}', avatar: '#{theme.waline.avatar}', @@ -14,14 +13,7 @@ script. emojiCDN: '#{theme.waline.emojiCDN}', emojiMaps: !{emojiMaps}, visitor: #{theme.waline.visitor} - } - - if (!{Boolean(option)}) { - const otherData = !{option} - initData = Object.assign(initData, otherData) - } - - const waline = new Waline(initData) + }, !{JSON.stringify(theme.waline.option)})) } if (typeof Waline === 'function') initWaline() diff --git a/package.json b/package.json index f18ac78..31bad5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "3.7.0-b3", + "version": "3.7.0-b4", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": {