diff --git a/_config.yml b/_config.yml index ff041a8..10c8756 100644 --- a/_config.yml +++ b/_config.yml @@ -20,7 +20,7 @@ menu: # Code Blocks (代碼相關) # -------------------------------------- -highlight_theme: light # default / darker / pale night / light / ocean / mac / false +highlight_theme: light # default / darker / pale night / light / ocean / mac / mac light / false highlight_copy: true # copy button highlight_lang: true # show the code language highlight_shrink: false # true: shrink the code blocks / false: expand the code blocks | none: expand code blocks and hide the button @@ -122,7 +122,7 @@ cover: # left/right/both position: both # When cover is not set, the default cover is displayed (當沒有設置cover時,默認的封面顯示) - default_cover: + default_cover: - https://i.loli.net/2020/05/01/gkihqEjXxJ5UZ1C.jpg # Replace Broken Images (替換無法顯示的圖片) @@ -200,6 +200,15 @@ photofigcaption: false # when you scroll in post, the URL will update according to header id. anchor: false +# Displays outdated notice for a post (文章過期提醒) +noticeOutdate: + enable: false + style: flat # style: simple/flat + limit_day: 500 # When will it be shown + position: top # position: top/bottom + message_prev: It has been + message_next: days since the last update, the content of the article may be outdated. + # Share System (分享功能) # -------------------------------------- @@ -231,18 +240,23 @@ addtoany: # Comments System # -------------------------------------- +comments: + # Up to two comments system, the first will be shown as default + # Disqus/Disqusjs/Livere/Gitalk/Valine/Utterances/Facebook Comments + use: + text: true # Display the comment name next to the button + load_begin: false # The second comment system will auto load when visiting the website + count: false # Dispaly comment count in top_img + # disqus # https://disqus.com/ disqus: - enable: false shortname: - count: false # dispaly comment count in top_img # Alternative Disqus - Render comments with Disqus API # DisqusJS評論系統,可以實現在網路審查地區載入 Disqus 評論列表,兼容原版 # https://github.com/SukkaW/DisqusJS disqusjs: - enable: false shortname: siteName: apikey: @@ -250,18 +264,15 @@ disqusjs: nocomment: # display when a blog post or an article has no comment attached admin: adminLabel: - count: false # dispaly comment count in top_img # livere(來必力) # https://www.livere.com/ livere: - enable: false uid: # gitalk # https://github.com/gitalk/gitalk gitalk: - enable: false client_id: client_secret: repo: @@ -272,12 +283,10 @@ gitalk: distractionFreeMode: false # Facebook-like distraction free mode. pagerDirection: last # Comment sorting direction, available values are last and first. createIssueManually: false # Gitalk will create a corresponding github issue for your every single page automatically - count: false # dispaly comment count in top_img # valine # https://valine.js.org valine: - enable: false # if you want use valine,please set this value is true appId: # leancloud application app id appKey: # leancloud application app key pageSize: 10 # comment list page size @@ -291,12 +300,10 @@ valine: emojiCDN: # emoji CDN enableQQ: false # enable the Nickname box to automatically get QQ Nickname and QQ Avatar requiredFields: nick,mail # required fields (nick/mail) - count: false # dispaly comment count in top_img # utterances # https://utteranc.es/ utterances: - enable: false repo: # Issue Mapping: pathname/url/title/og:title issue_term: pathname @@ -307,13 +314,11 @@ utterances: # Facebook Comments Plugin # https://developers.facebook.com/docs/plugins/comments/ facebook_comments: - enable: false app_id: user_id: # optional pageSize: 10 # The number of comments to show order_by: social # social/time/reverse_time lang: en_US # Language en_US/zh_CN/zh_TW and so on - count: false # Chat Services # -------------------------------------- @@ -736,7 +741,7 @@ fragment_cache: true # 插入代码到头部 之前 和 底部 之前 inject: head: - # - + # - bottom: # - diff --git a/layout/includes/comments/disqus.pug b/layout/includes/comments/disqus.pug index 661f53f..679b170 100644 --- a/layout/includes/comments/disqus.pug +++ b/layout/includes/comments/disqus.pug @@ -1,18 +1,28 @@ #disqus_thread script. - var disqus_config = function () { - this.page.url = '!{ page.permalink }'; - this.page.identifier = '!{ page.path }'; - this.page.title = '!{ page.title }'; - }; - (function() { + function loadDisqus () { + var disqus_config = function () { + this.page.url = '!{ page.permalink }'; + this.page.identifier = '!{ page.path }'; + this.page.title = '!{ page.title }'; + }; + var d = document, s = d.createElement('script'); s.src = 'https://!{theme.disqus.shortname}.disqus.com/embed.js'; s.setAttribute('data-timestamp', +new Date()); (d.head || d.body).appendChild(s); - })(); + } -if is_post() && theme.disqus.count + if ('!{defaultComment}' === 'Disqus' || !{theme.comments.load_begin}) { + window.addEventListener('load', loadDisqus) + } + else { + function loadOtherComment () { + loadDisqus() + } + } + +if is_post() && theme.comments.count && defaultComment === 'Disqus' script. function getDisqusCount() { var d = document, s = d.createElement('script'); diff --git a/layout/includes/comments/disqusjs.pug b/layout/includes/comments/disqusjs.pug index 7d670d2..4a1eb50 100644 --- a/layout/includes/comments/disqusjs.pug +++ b/layout/includes/comments/disqusjs.pug @@ -1,20 +1,38 @@ #disqus_thread -script(src=url_for(theme.CDN.disqusjs)) script. - var dsqjs = new DisqusJS({ - shortname: '!{theme.disqusjs.shortname}', - siteName: '!{theme.disqusjs.siteName}', - identifier: '!{ page.path }', - url: '!{ page.permalink }', - title: '!{ page.title }', - api: '!{theme.disqusjs.api}', - apikey: '!{theme.disqusjs.apikey}', - nocomment: '!{theme.disqusjs.nocomment}', - admin: '!{theme.disqusjs.admin}', - adminLabel: '!{theme.disqusjs.adminLabel}' - }); + function loadDisqusjs () { + const ele = document.createElement('link') + ele.rel = 'stylesheet' + ele.href= '!{url_for(theme.CDN.disqusjs_css)}' + document.getElementsByTagName('head')[0].appendChild(ele) -if is_post() && theme.disqusjs.count + loadScript('!{url_for(theme.CDN.disqusjs)}', function() { + var dsqjs = new DisqusJS({ + shortname: '!{theme.disqusjs.shortname}', + siteName: '!{theme.disqusjs.siteName}', + identifier: '!{ page.path }', + url: '!{ page.permalink }', + title: '!{ page.title }', + api: '!{theme.disqusjs.api}', + apikey: '!{theme.disqusjs.apikey}', + nocomment: '!{theme.disqusjs.nocomment}', + admin: '!{theme.disqusjs.admin}', + adminLabel: '!{theme.disqusjs.adminLabel}' + }); + }) + } + + if ('!{defaultComment}' === 'Disqusjs' || !{theme.comments.load_begin}) { + window.addEventListener('load', loadDisqusjs) + } + else { + function loadOtherComment () { + loadDisqusjs() + } + } + + +if is_post() && theme.comments.count && defaultComment === 'Disqusjs' script. function getDisqusCount() { var d = document, s = d.createElement('script'); diff --git a/layout/includes/comments/facebook_comments.pug b/layout/includes/comments/facebook_comments.pug index 50f8838..d1bda44 100644 --- a/layout/includes/comments/facebook_comments.pug +++ b/layout/includes/comments/facebook_comments.pug @@ -1,11 +1,29 @@ #fb-root -script(async defer crossorigin="anonymous" src=`https://connect.facebook.net/${theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v6.0`) .fb-comments(data-colorscheme = theme.display_mode === 'dark' ? 'dark' : 'light' data-href=urlNoIndex() data-numposts= theme.facebook_comments.pageSize || 10 data-order-by= theme.facebook_comments.order_by || 'social' data-width="100%") +script. + function loadFBComent () { + let ele = document.createElement('script') + ele.setAttribute('src','https://connect.facebook.net/!{theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v7.0') + ele.setAttribute('async', 'true') + ele.setAttribute('defer', 'true') + ele.setAttribute('crossorigin', 'anonymous') + document.getElementById('fb-root').insertAdjacentElement('afterbegin',ele) + } + + if ('!{defaultComment}' === 'Facebook Comments' || !{theme.comments.load_begin}) { + window.addEventListener('load', loadFBComent) + } + else { + function loadOtherComment () { + loadFBComent() + } + } + if theme.darkmode.enable script. var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light' diff --git a/layout/includes/comments/gitalk.pug b/layout/includes/comments/gitalk.pug index 9a1fee9..6ee8270 100644 --- a/layout/includes/comments/gitalk.pug +++ b/layout/includes/comments/gitalk.pug @@ -1,26 +1,46 @@ #gitalk-container -script. - var gitalk = new Gitalk({ - clientID: '!{theme.gitalk.client_id}', - clientSecret: '!{theme.gitalk.client_secret}', - repo: '!{theme.gitalk.repo}', - owner: '!{theme.gitalk.owner}', - admin: ['!{theme.gitalk.admin}'], - id: md5(decodeURI(location.pathname)), - language: '!{theme.gitalk.language}', - perPage: !{theme.gitalk.perPage}, - distractionFreeMode: !{theme.gitalk.distractionFreeMode}, - pagerDirection: '!{theme.gitalk.pagerDirection}', - createIssueManually: !{theme.gitalk.createIssueManually}, - updateCountCallback: commentCount - }) - gitalk.render('gitalk-container') +script(src=url_for(theme.CDN.blueimp_md5)) - function commentCount(n){ - try { - document.getElementsByClassName('gitalk-comment-count')[0].innerHTML= n - } catch (e) { - return false +script. + function loadGitalk () { + const ele = document.createElement('link') + ele.rel = 'stylesheet' + ele.href= '!{url_for(theme.CDN.gitalk_css)}' + document.getElementsByTagName('head')[0].appendChild(ele) + + loadScript('!{url_for(theme.CDN.gitalk)}', function () { + var gitalk = new Gitalk({ + clientID: '!{theme.gitalk.client_id}', + clientSecret: '!{theme.gitalk.client_secret}', + repo: '!{theme.gitalk.repo}', + owner: '!{theme.gitalk.owner}', + admin: ['!{theme.gitalk.admin}'], + id: md5(decodeURI(location.pathname)), + language: '!{theme.gitalk.language}', + perPage: !{theme.gitalk.perPage}, + distractionFreeMode: !{theme.gitalk.distractionFreeMode}, + pagerDirection: '!{theme.gitalk.pagerDirection}', + createIssueManually: !{theme.gitalk.createIssueManually}, + updateCountCallback: commentCount + }) + gitalk.render('gitalk-container') + }) + + function commentCount(n){ + try { + document.getElementsByClassName('gitalk-comment-count')[0].innerHTML= n + } catch (e) { + return false + } + } + } + + if ('!{defaultComment}' === 'Gitalk' || !{theme.comments.load_begin}) { + window.addEventListener('load', loadGitalk) + } + else { + function loadOtherComment () { + loadGitalk() } } diff --git a/layout/includes/comments/index.pug b/layout/includes/comments/index.pug index a8d1a92..9c098a9 100644 --- a/layout/includes/comments/index.pug +++ b/layout/includes/comments/index.pug @@ -1,29 +1,36 @@ -- var d = theme.disqus && theme.disqus.enable -- var dj = theme.disqusjs && theme.disqusjs.enable -- var l = theme.livere && theme.livere.enable -- var gt = theme.gitalk && theme.gitalk.enable -- var v = theme.valine && theme.valine.enable -- var u = theme.utterances && theme.utterances.enable -- var fb = theme.facebook_comments && theme.facebook_comments.enable -- var isComment = d || dj || l || gt || v || u || fb - -if isComment +if theme.comments && theme.comments.use + - const defaultComment = theme.comments.use[0] hr #post-comment - .comment_headling - i.fas.fa-comments.fa-fw - span= ' ' + _p('comment') - if d - include ./disqus.pug - else if dj - include ./disqusjs.pug - else if l - include ./livere.pug - else if gt - include ./gitalk.pug - else if v - include ./valine.pug - else if u - include ./utterances.pug - else if fb - include ./facebook_comments.pug \ No newline at end of file + .comment-head + .comment-headling + i.fas.fa-comments.fa-fw + span= ' ' + _p('comment') + + if theme.comments.use.length > 1 + .comment-switch + span.first-comment=defaultComment + label + input#switch-comments-btn(type="checkbox") + span.slider + span.second-comment=theme.comments.use[1] + + + .comment-wrap + each name, index in theme.comments.use + div(class=`comments-items-${index+1}` data-name=`${name}`) + case name + when 'Disqus' + include ./disqus.pug + when 'Valine' + include ./valine.pug + when 'Disqusjs' + include ./disqusjs.pug + when 'Livere' + include ./livere.pug + when 'Gitalk' + include ./gitalk.pug + when 'Utterances' + include ./utterances.pug + when 'Facebook Comments' + include ./facebook_comments.pug \ No newline at end of file diff --git a/layout/includes/comments/livere.pug b/layout/includes/comments/livere.pug index f530901..9ba04a9 100644 --- a/layout/includes/comments/livere.pug +++ b/layout/includes/comments/livere.pug @@ -1,10 +1,21 @@ #lv-container(data-id="city" data-uid=theme.livere.uid) script. - (function(d, s) { - var j, e = d.getElementsByTagName(s)[0]; - if (typeof LivereTower === 'function') { return; } - j = d.createElement(s); - j.src = 'https://cdn-city.livere.com/js/embed.dist.js'; - j.async = true; - e.parentNode.insertBefore(j, e); - })(document, 'script'); + function loadlivere () { + (function(d, s) { + var j, e = d.getElementsByTagName(s)[0]; + if (typeof LivereTower === 'function') { return; } + j = d.createElement(s); + j.src = 'https://cdn-city.livere.com/js/embed.dist.js'; + j.async = true; + e.parentNode.insertBefore(j, e); + })(document, 'script'); + } + + if ('!{defaultComment}' === 'Livere' || !{theme.comments.load_begin}) { + window.addEventListener('load', loadlivere) + } + else { + function loadOtherComment () { + loadlivere() + } + } \ No newline at end of file diff --git a/layout/includes/comments/utterances.pug b/layout/includes/comments/utterances.pug index d9cc76d..6876a85 100644 --- a/layout/includes/comments/utterances.pug +++ b/layout/includes/comments/utterances.pug @@ -1,15 +1,30 @@ -script#utterances_comment(src=theme.CDN.utterances - repo=theme.utterances.repo - issue-term=theme.utterances.issue_term - theme= theme.display_mode === 'dark' ? theme.utterances.dark_theme : theme.utterances.light_theme - crossorigin="anonymous" - async) +#utterances-wrap + +script. + function loadUtterances () { + let ele = document.createElement('script') + ele.setAttribute('id', 'utterances_comment') + ele.setAttribute('src', '!{url_for(theme.CDN.utterances)}') + ele.setAttribute('repo', '!{theme.utterances.repo}') + ele.setAttribute('issue-term', '!{theme.utterances.issue_term}') + let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}' + ele.setAttribute('theme', nowTheme) + ele.setAttribute('crossorigin', 'anonymous') + ele.setAttribute('async', 'true') + document.getElementById('utterances-wrap').insertAdjacentElement('afterbegin',ele) + } + + if ('!{defaultComment}' === 'Utterances' || !{theme.comments.load_begin}) { + window.addEventListener('load', loadUtterances) + } + else { + function loadOtherComment () { + loadUtterances() + } + } if theme.darkmode.enable script. - var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}' - document.getElementById('utterances_comment').setAttribute('theme',themeNow) - function utterancesTheme () { var theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}' const message = { diff --git a/layout/includes/comments/valine.pug b/layout/includes/comments/valine.pug index d5c7493..a3736fb 100644 --- a/layout/includes/comments/valine.pug +++ b/layout/includes/comments/valine.pug @@ -3,33 +3,47 @@ if site.data.valine - emojiMaps = JSON.stringify(site.data.valine) #vcomment.vcomment -script(src=url_for(theme.CDN.valine)) script. - var requestSetting = function (from,set) { - var from = from - var setting = set.split(',').filter(function(item){ - return from.indexOf(item) > -1 - }); - setting = setting.length == 0 ? from :setting; - return setting + function loadvaline () { + var requestSetting = function (from,set) { + var from = from + var setting = set.split(',').filter(function(item){ + return from.indexOf(item) > -1 + }); + setting = setting.length == 0 ? from :setting; + return setting + } + + var guestInfo = requestSetting(['nick','mail','link'],'#{ theme.valine.guest_info }') + var requiredFields = requestSetting(['nick','mail'],'#{ theme.valine.requiredFields }') + + function initValine () { + window.valine = new Valine({ + el:'#vcomment', + appId: '#{theme.valine.appId}', + appKey: '#{theme.valine.appKey}', + placeholder: '#{theme.valine.placeholder}', + avatar: '#{theme.valine.avatar}', + meta: guestInfo, + pageSize: '#{theme.valine.pageSize}', + lang: '#{theme.valine.lang}', + recordIP: #{theme.valine.recordIP}, + serverURLs: '#{theme.valine.serverURLs}', + emojiCDN: '#{theme.valine.emojiCDN}', + emojiMaps: !{emojiMaps}, + enableQQ: #{theme.valine.enableQQ}, + requiredFields: requiredFields + }); + } + loadScript('!{url_for(theme.CDN.valine)}', initValine) } - var guestInfo = requestSetting(['nick','mail','link'],'#{ theme.valine.guest_info }') - var requiredFields = requestSetting(['nick','mail'],'#{ theme.valine.requiredFields }') + if ('!{defaultComment}' === 'Valine' || !{theme.comments.load_begin}) { + window.addEventListener('load', loadvaline) + } + else { + function loadOtherComment () { + loadvaline() + } + } - window.valine = new Valine({ - el:'#vcomment', - appId: '#{theme.valine.appId}', - appKey: '#{theme.valine.appKey}', - placeholder: '#{theme.valine.placeholder}', - avatar: '#{theme.valine.avatar}', - meta: guestInfo, - pageSize: '#{theme.valine.pageSize}', - lang: '#{theme.valine.lang}', - recordIP: #{theme.valine.recordIP}, - serverURLs: '#{theme.valine.serverURLs}', - emojiCDN: '#{theme.valine.emojiCDN}', - emojiMaps: !{emojiMaps}, - enableQQ: #{theme.valine.enableQQ}, - requiredFields: requiredFields - }); diff --git a/layout/includes/head/comment.pug b/layout/includes/head/comment.pug index 3597780..caa2f6d 100644 --- a/layout/includes/head/comment.pug +++ b/layout/includes/head/comment.pug @@ -1,14 +1,5 @@ -if (theme.facebook_comments.enable && page.comments !== false && !is_tag() && !is_category() && !is_archive() && !is_home()) +if page.comments !== false && theme.comments.use && theme.comments.use.includes('Facebook Comments') if theme.facebook_comments.app_id meta(property="fb:app_id" content=theme.facebook_comments.app_id ) if theme.facebook_comments.user_id - meta(property="fb:admins" content=theme.facebook_comments.user_id) - -if (theme.disqusjs && theme.disqusjs.enable && page.comments !== false && !is_tag() && !is_category() && !is_archive() && !is_home()) - link(rel="stylesheet" type="text/css" href=url_for(theme.CDN.disqusjs_css)) - -if (theme.gitalk && theme.gitalk.enable && page.comments !== false && !is_tag() && !is_category() && !is_archive() && !is_home()) - link(rel="stylesheet" type="text/css" href=url_for(theme.CDN.gitalk_css)) - script(src=url_for(theme.CDN.gitalk)) - script(src=url_for(theme.CDN.blueimp_md5)) - + meta(property="fb:admins" content=theme.facebook_comments.user_id) \ No newline at end of file diff --git a/layout/includes/head/config.pug b/layout/includes/head/config.pug index 3ffe6d2..320d2a0 100644 --- a/layout/includes/head/config.pug +++ b/layout/includes/head/config.pug @@ -74,12 +74,23 @@ }) } + var noticeOutdate = 'undefined'; + if (theme.noticeOutdate && theme.noticeOutdate.enable) { + noticeOutdate = JSON.stringify({ + limitDay: theme.noticeOutdate.limit_day, + position: theme.noticeOutdate.position, + messagePrev: theme.noticeOutdate.message_prev, + messageNext: theme.noticeOutdate.message_next, + }) + } + script. var GLOBAL_CONFIG = { root: '!{config.root}', algolia: !{algolia}, localSearch: !{localSearch}, translate: !{translate}, + noticeOutdate: !{noticeOutdate}, copy: { success: '!{_p("copy.success")}', error: '!{_p("copy.error")}', diff --git a/layout/includes/head/config_site.pug b/layout/includes/head/config_site.pug index 84167e8..764f80f 100644 --- a/layout/includes/head/config_site.pug +++ b/layout/includes/head/config_site.pug @@ -1,10 +1,10 @@ - let isHighlightShrink if (theme.highlight_shrink == 'none') isHighlightShrink = 'undefined' - else if (page.highlight_shrink !== null && page.toc !== undefined ) isHighlightShrink = page.highlight_shrink + else if (page.highlight_shrink === true || page.highlight_shrink === false) isHighlightShrink = page.highlight_shrink else isHighlightShrink = theme.highlight_shrink - const pageToc = page.toc !== null && page.toc !== undefined ? page.toc : theme.toc.enable + const pageToc = page.toc === true || page.toc === false ? page.toc : theme.toc.enable const showToc = is_post() && pageToc && (toc(page.content) !== '' || page.encrypt == true ) - @@ -13,5 +13,6 @@ script. isPost: !{is_post()}, isHome: !{is_home()}, isHighlightShrink: !{isHighlightShrink}, - isSidebar: !{showToc} - } + isSidebar: !{showToc}, + postUpdate: '!{full_date(page.updated)}' + } diff --git a/layout/includes/head/pwa.pug b/layout/includes/head/pwa.pug index ca927dc..f318808 100644 --- a/layout/includes/head/pwa.pug +++ b/layout/includes/head/pwa.pug @@ -1,13 +1,13 @@ -link(rel="manifest" href=theme.pwa.manifest) +link(rel="manifest" href=url_for(theme.pwa.manifest)) if(theme.pwa.theme_color) meta(name="theme-color" content=theme.pwa.theme_color) if(theme.pwa.theme_color) meta(name="msapplication-TileColor" content=theme.pwa.theme_color) if(theme.pwa.apple_touch_icon) - link(rel="apple-touch-icon" sizes="180x180" href=theme.pwa.apple_touch_icon) + link(rel="apple-touch-icon" sizes="180x180" href=url_for(theme.pwa.apple_touch_icon)) if(theme.pwa.favicon_32_32) - link(rel="icon" type="image/png" sizes="32x32" href=theme.pwa.favicon_32_32) + link(rel="icon" type="image/png" sizes="32x32" href=url_for(theme.pwa.favicon_32_32)) if(theme.pwa.favicon_16_16) - link(rel="icon" type="image/png" sizes="16x16" href=theme.pwa.favicon_16_16) + link(rel="icon" type="image/png" sizes="16x16" href=url_for(theme.pwa.favicon_16_16)) if(theme.pwa.mask_icon) - link(rel="mask-icon" href=theme.pwa.mask_icon color="#5bbad5") + link(rel="mask-icon" href=url_for(theme.pwa.mask_icon) color="#5bbad5") diff --git a/layout/includes/header/post-info.pug b/layout/includes/header/post-info.pug index 63439df..a412631 100644 --- a/layout/includes/header/post-info.pug +++ b/layout/includes/header/post-info.pug @@ -57,29 +57,32 @@ span=_p('post.page_pv') + ':' span#busuanzi_value_page_pv - span.post-meta-commentcount - if ((theme.disqus && theme.disqus.enable && theme.disqus.count && page.comments !== false) || (theme.disqusjs && theme.disqusjs.enable && theme.disqusjs.count && page.comments !== false)) + if page.comments !== false && theme.comments.use && theme.comments.count + span.post-meta-commentcount + + - let whichCount = theme.comments.use[0] + if whichCount === 'Disqus' || whichCount === 'Disqusjs' if (postWordcount || theme.busuanzi.page_pv) span.post-meta__separator | i.far.fa-comments.fa-fw.post-meta__icon span= _p('post.comments') + ':' span.disqus-comment-count.comment-count a(href=full_url_for(page.path) + '#disqus_thread') - else if (theme.valine && theme.valine.enable && theme.valine.count && page.comments !== false) + else if whichCount === 'Valine' if (postWordcount || theme.busuanzi.page_pv) span.post-meta__separator | i.far.fa-comments.fa-fw.post-meta__icon span= _p('post.comments') + ':' a(href=url_for(page.path) + '#post-comment' itemprop="discussionUrl") span.valine-comment-count.comment-count(data-xid=url_for(page.path) itemprop="commentCount") - else if (theme.gitalk && theme.gitalk.enable && theme.gitalk.count && page.comments !== false) + else if whichCount === 'Gitalk' if (postWordcount || theme.busuanzi.page_pv) span.post-meta__separator | i.far.fa-comments.fa-fw.post-meta__icon span= _p('post.comments') + ':' a(href=url_for(page.path) + '#post-comment') span.gitalk-comment-count.comment-count - else if theme.facebook_comments.enable && theme.facebook_comments.count && page.comments !== false + else if whichCount === 'Facebook Comments' if (postWordcount || theme.busuanzi.page_pv) span.post-meta__separator | i.far.fa-comments.fa-fw.post-meta__icon diff --git a/layout/includes/layout.pug b/layout/includes/layout.pug index dae1612..5eb8158 100644 --- a/layout/includes/layout.pug +++ b/layout/includes/layout.pug @@ -1,5 +1,5 @@ - var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : '' -- var pageHighlightShrinkSet = page.highlight_shrink !== undefined ? page.highlight_shrink : theme.highlight_shrink +- var pageHighlightShrinkSet = page.highlight_shrink === true || page.highlight_shrink === false ? page.highlight_shrink : theme.highlight_shrink - var pageHighlightShrink = theme.highlight_shrink !== 'none' && pageHighlightShrinkSet ? 'code-close' : '' doctype html diff --git a/layout/includes/post/post-copyright.pug b/layout/includes/post/post-copyright.pug index ee8c659..dfa346d 100644 --- a/layout/includes/post/post-copyright.pug +++ b/layout/includes/post/post-copyright.pug @@ -1,13 +1,17 @@ -if (theme.post_copyright && theme.post_copyright.enable && page.copyright != false) +if theme.post_copyright.enable && page.copyright !== false + - let author = page.copyright_author ? page.copyright_author : config.author + - let authorHref = page.copyright_author_href ? page.copyright_author_href : `mailto:${config.email}` + - let url = page.copyright_url ? page.copyright_url : page.permalink + - let info = page.copyright_info ? page.copyright_info : _p('post.copyright.copyright_content', theme.post_copyright.license_url, theme.post_copyright.license, config.url, config.title) .post-copyright .post-copyright__author span.post-copyright-meta= _p('post.copyright.author') + ": " span.post-copyright-info - a(href=`mailto:${config.email}`) #[=config.author] + a(href=authorHref)=author .post-copyright__type span.post-copyright-meta= _p('post.copyright.link') + ": " span.post-copyright-info - a(href=url_for(page.permalink))= theme.post_copyright.decode ? decodeURI(page.permalink) : page.permalink + a(href=url_for(url))= theme.post_copyright.decode ? decodeURI(url) : url .post-copyright__notice span.post-copyright-meta= _p('post.copyright.copyright_notice') + ": " - span.post-copyright-info!= _p('post.copyright.copyright_content', theme.post_copyright.license_url, theme.post_copyright.license, config.url, config.title) + span.post-copyright-info!= info diff --git a/layout/includes/post/reward.pug b/layout/includes/post/reward.pug index 3c5ac28..98b897b 100644 --- a/layout/includes/post/reward.pug +++ b/layout/includes/post/reward.pug @@ -1,5 +1,5 @@ .post-reward - button.reward-button + button.reward-button(type="button") i.fas.fa-qrcode = ' ' + _p('donate') .reward-main diff --git a/layout/includes/rightside.pug b/layout/includes/rightside.pug index 90e0dc0..d55fcf5 100644 --- a/layout/includes/rightside.pug +++ b/layout/includes/rightside.pug @@ -1,32 +1,32 @@ -section#rightside.rightside +section#rightside #rightside-config-hide if is_post() if theme.readmode - button#readmode(title=_p('rightside.readmode_title')) + button#readmode(type="button" title=_p('rightside.readmode_title')) i.fas.fa-book-open - button#font_plus(title=_p('rightside.font_plus_title')) + button#font_plus(type="button" title=_p('rightside.font_plus_title')) i.fas.fa-plus - button#font_minus(title=_p('rightside.font_minus_title')) + button#font_minus(type="button" title=_p('rightside.font_minus_title')) i.fas.fa-minus if theme.translate && theme.translate.enable - button#translateLink.translate_chn_to_cht(title=_p('rightside.translate_title'))= theme.translate.default + button#translateLink(type="button" title=_p('rightside.translate_title'))= theme.translate.default if theme.darkmode.enable && theme.darkmode.button - button#darkmode(title=_p('rightside.night_mode_title')) + button#darkmode(type="button" title=_p('rightside.night_mode_title')) i.fas.fa-adjust #rightside-config-show - button#rightside_config(title=_p("rightside.setting")) + button#rightside_config(type="button" title=_p("rightside.setting")) i.fas.fa-cog - if is_post() && page.comments !== false && isComment + if is_post() && page.comments !== false && theme.comments.use a#to_comment(href="#post-comment" title=_p("rightside.scroll_to_comment")) - i.scroll_to_comment.fas.fa-comments + i.fas.fa-comments if showToc - button#mobile-toc-button.close(title=_p("rightside.toc")) + button#mobile-toc-button.close(type="button" title=_p("rightside.toc")) i.fas.fa-list-ul if theme.chat_btn && (theme.chatra.enable || theme.tidio.enable || theme.daovoice.enable || theme.gitter.enable) - button#chat_btn(title=_p("rightside.chat_btn")) + button#chat_btn(type="button" title=_p("rightside.chat_btn")) i.fas.fa-sms - button#go-up(title=_p("rightside.back_to_top")) + button#go-up(type="button" title=_p("rightside.back_to_top")) i.fas.fa-arrow-up diff --git a/layout/includes/widget/card_author.pug b/layout/includes/widget/card_author.pug index 95fea9d..ce9bd69 100644 --- a/layout/includes/widget/card_author.pug +++ b/layout/includes/widget/card_author.pug @@ -25,7 +25,7 @@ .length_num= site.categories.length .card-info-bookmark.is-center - button#bookmark-it.button--animated(title= _p('aside.card_bookmark')) + button#bookmark-it.button--animated(type="button" title= _p('aside.card_bookmark')) i.fas.fa-bookmark span= _p('aside.card_bookmark') || 'Follow Me' diff --git a/package.json b/package.json index 641ee07..63a21cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "3.0.0-rc-1", + "version": "3.0.0", "private": true, "engines": { "node": ">=8.10.0" diff --git a/scripts/filters/post_lazyload.js b/scripts/filters/post_lazyload.js index 3ae664c..5bbde39 100644 --- a/scripts/filters/post_lazyload.js +++ b/scripts/filters/post_lazyload.js @@ -10,11 +10,11 @@ const urlFor = require('hexo-util').url_for.bind(hexo) function lazyProcess (htmlContent) { - var bg = hexo.theme.config.lazyload.post ? urlFor(hexo.theme.config.lazyload.post) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=' + const bg = hexo.theme.config.lazyload.post ? urlFor(hexo.theme.config.lazyload.post) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=' return htmlContent.replace(/( { let result = '' - var isTopParent = topparent + const isTopParent = topparent if (t > 0) { prepareQuery(parent).forEach((cat, i) => { if (t > 0) { t = t - 1 let child if (!depth || level + 1 < depth) { - var childList = hierarchicalList(t, level + 1, cat._id, false) + const childList = hierarchicalList(t, level + 1, cat._id, false) child = childList[0] t = childList[1] } - var parentClass = isExpand && isTopParent && child ? 'parent' : '' + const parentClass = isExpand && isTopParent && child ? 'parent' : '' result += `
  • ` @@ -79,8 +79,8 @@ hexo.extend.helper.register('aside_categories', function (categories, options) { const list = hierarchicalList(limit, 0) - var moreButton = function () { - var moreHtml = '' + const moreButton = function () { + let moreHtml = '' if (categories.length <= limit) return '' moreHtml += '
  • ' moreHtml += ` diff --git a/scripts/helpers/page.js b/scripts/helpers/page.js index 74e7674..ed68bcf 100644 --- a/scripts/helpers/page.js +++ b/scripts/helpers/page.js @@ -25,7 +25,7 @@ hexo.extend.helper.register('page_description', function () { hexo.extend.helper.register('injectHtml', function (data) { let result = '' if (!data) return '' - for (var i = 0; i < data.length; i++) { + for (let i = 0; i < data.length; i++) { result += data[i] } return result @@ -41,8 +41,8 @@ hexo.extend.helper.register('cloudTags', function (options = {}) { let result = '' const tagLimit = limit === 0 ? source.length : limit source.sort('name').limit(tagLimit).forEach(function (tags) { - var fontSize = Math.floor(Math.random() * (maxfontsize - minfontsize) + minfontsize) + 'px' - var color = 'rgb(' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ')' // 0,0,0 -> 200,200,200 + const fontSize = Math.floor(Math.random() * (maxfontsize - minfontsize) + minfontsize) + 'px' + const color = 'rgb(' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ')' // 0,0,0 -> 200,200,200 result += `${tags.name}` }) return result diff --git a/scripts/helpers/related_post.js b/scripts/helpers/related_post.js index 60c1e6c..8b036f2 100644 --- a/scripts/helpers/related_post.js +++ b/scripts/helpers/related_post.js @@ -7,11 +7,11 @@ 'use strict' hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { - var relatedPosts = [] + let relatedPosts = [] currentPost.tags.forEach(function (tag) { allPosts.forEach(function (post) { if (isTagRelated(tag.name, post.tags)) { - var relatedPost = { + const relatedPost = { title: post.title, path: post.path, cover: post.cover, @@ -20,7 +20,7 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { updated: post.updated, created: post.date } - var index = findItem(relatedPosts, 'path', post.path) + const index = findItem(relatedPosts, 'path', post.path) if (index !== -1) { relatedPosts[index].weight += 1 } else { @@ -34,14 +34,14 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { if (relatedPosts.length === 0) { return '' } - var result = '' + let result = '' const hexoConfig = hexo.theme.config.rootConfig const config = hexo.theme.config - var limitNum = config.related_post.limit || 6 - var dateType = config.related_post.date_type || 'created' - var headlineLang = this._p('post.recommend') - var lazySrc = config.lazyload.enable ? 'data-src' : 'src' + const limitNum = config.related_post.limit || 6 + const dateType = config.related_post.date_type || 'created' + const headlineLang = this._p('post.recommend') + const lazySrc = config.lazyload.enable ? 'data-src' : 'src' relatedPosts = relatedPosts.sort(compare('weight')) @@ -54,8 +54,8 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { '' result += '