From b176ff0fa70a17eb21060335463085bdc5f0d0d7 Mon Sep 17 00:00:00 2001 From: Jerry Date: Fri, 19 Feb 2021 22:14:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0waline,valine=20?= =?UTF-8?q?=E5=92=8Ctwikoo=20=E6=8F=90=E4=BE=9B=E7=9A=84=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E9=96=B2=E8=AE=80=E6=95=B8=E9=85=8D=E7=BD=AE=20close=20#502=20?= =?UTF-8?q?improvement:=20=E7=95=B6=E6=96=87=E7=AB=A0=E9=A0=81cover=20?= =?UTF-8?q?=E5=92=8Ccover=20=E7=9A=84=20default=5Fimg=E9=83=BD=E6=B2=92?= =?UTF-8?q?=E6=9C=89=E9=85=8D=E7=BD=AE=E6=99=82=EF=BC=8C=E6=9C=83=E5=8E=BB?= =?UTF-8?q?=E8=AE=80=E5=8F=96default=5Ftop=5Fimg=E7=9A=84=E5=8F=83?= =?UTF-8?q?=E6=95=B8=20improvement:=20=E5=9C=A8=E5=AE=8C=E5=85=A8=E6=B2=92?= =?UTF-8?q?=E6=9C=89=E9=85=8D=E7=BD=AE=E7=9A=84=E6=83=85=E6=B3=81=E4=B8=8B?= =?UTF-8?q?=EF=BC=8C=E9=81=8B=E8=A1=8C=E6=99=82=E6=8E=A7=E5=88=B6=E8=87=BA?= =?UTF-8?q?=E5=A0=B1null=20=E7=9A=84=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 3 +++ layout/includes/head/Open_Graph.pug | 2 +- layout/includes/header/index.pug | 2 +- layout/includes/header/post-info.pug | 24 +++++++++++++++---- layout/includes/sidebar.pug | 11 +++++---- .../includes/third-party/comments/valine.pug | 1 + .../includes/third-party/comments/waline.pug | 1 + layout/includes/widget/card_author.pug | 9 +++---- layout/includes/widget/card_tags.pug | 2 +- package.json | 2 +- scripts/filters/random_cover.js | 2 +- source/css/_layout/aside.styl | 2 +- 12 files changed, 41 insertions(+), 20 deletions(-) diff --git a/_config.yml b/_config.yml index 771dd2f..5a9ead4 100644 --- a/_config.yml +++ b/_config.yml @@ -321,6 +321,7 @@ 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) + visitor: false option: # waline - A simple comment system with backend support fork from Valine @@ -330,6 +331,7 @@ waline: avatar: monsterid # gravatar style https://zh-tw.gravatar.com/site/implement/images/#default-image emojiCDN: # emoji CDN bg: # waline background + visitor: false option: # utterances @@ -356,6 +358,7 @@ facebook_comments: twikoo: envId: region: + visitor: false option: # Chat Services diff --git a/layout/includes/head/Open_Graph.pug b/layout/includes/head/Open_Graph.pug index 7d5c59c..1702985 100644 --- a/layout/includes/head/Open_Graph.pug +++ b/layout/includes/head/Open_Graph.pug @@ -1,6 +1,6 @@ if theme.Open_Graph_meta - let contentType = is_post() ? 'article' : 'website' - - let metaImage = full_url_for(page.cover || theme.avatar.img) + - let metaImage = (page.cover || theme.avatar.img) ? full_url_for(page.cover || theme.avatar.img) : '' - let fb_appId = theme.facebook_comments.app_id || '' - let fb_admins = theme.facebook_comments.user_id || '' diff --git a/layout/includes/header/index.pug b/layout/includes/header/index.pug index ed02549..2476015 100644 --- a/layout/includes/header/index.pug +++ b/layout/includes/header/index.pug @@ -1,6 +1,6 @@ if !theme.disable_top_img && page.top_img !== false if is_post() - - var top_img = page.top_img || page.cover || page.randomcover || theme.default_top_img + - var top_img = page.top_img || page.cover || page.randomcover else if is_page() - var top_img = page.top_img || theme.default_top_img else if is_tag() diff --git a/layout/includes/header/post-info.pug b/layout/includes/header/post-info.pug index 7e2d4c1..0b11b61 100644 --- a/layout/includes/header/post-info.pug +++ b/layout/includes/header/post-info.pug @@ -1,3 +1,4 @@ +- let comments = theme.comments #post-info h1.post-title= page.title || _p('no_title') if theme.post_edit.enable @@ -51,15 +52,28 @@ span.post-meta-label= _p('post.min2read') + ':' span= min2read(page.content, {cn: 350, en: 160}) + _p('post.min2read_unit') - if theme.busuanzi.page_pv + //- for pv and count + mixin pvBlock(parent_id,parent_class) span.post-meta-separator | - span.post-meta-pv-cv + span(class=parent_class id=parent_id) i.far.fa-eye.fa-fw.post-meta-icon span.post-meta-label=_p('post.page_pv') + ':' - span#busuanzi_value_page_pv + if block + block - if !theme.comments.lazyload && page.comments !== false && theme.comments.use && theme.comments.count - - var whichCount = theme.comments.use[0] + if theme.busuanzi.page_pv + +pvBlock('','post-meta-pv-cv') + span#busuanzi_value_page_pv + else if comments.use && !comments.lazyload + if (comments.use.includes('Valine') && theme.valine.visitor) || (comments.use.includes('Waline') && theme.waline.visitor) + +pvBlock(url_for(page.path),'leancloud_visitors') + span.leancloud-visitors-count + else if (comments.use.includes('Twikoo') && theme.twikoo.visitor) + +pvBlock('','') + span#twikoo_visitors + + if comments.count && !comments.lazyload && page.comments !== false && comments.use + - var whichCount = comments.use[0] mixin countBlock span.post-meta-separator | diff --git a/layout/includes/sidebar.pug b/layout/includes/sidebar.pug index 43c0b2c..1bce458 100644 --- a/layout/includes/sidebar.pug +++ b/layout/includes/sidebar.pug @@ -1,11 +1,12 @@ #sidebar #menu-mask #sidebar-menus - .author-avatar - if theme.lazyload.enable - img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar") - else - img.avatar-img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar") + if theme.avatar.img + .author-avatar + if theme.lazyload.enable + img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar") + else + img.avatar-img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar") .site-data if site.posts.length .data-item.is-center diff --git a/layout/includes/third-party/comments/valine.pug b/layout/includes/third-party/comments/valine.pug index e67f92b..249a4e3 100644 --- a/layout/includes/third-party/comments/valine.pug +++ b/layout/includes/third-party/comments/valine.pug @@ -21,6 +21,7 @@ script. emojiMaps: !{emojiMaps}, enableQQ: #{theme.valine.enableQQ}, path: window.location.pathname, + visitor: #{theme.valine.visitor} } if (!{Boolean(theme.valine.requiredFields)}) { diff --git a/layout/includes/third-party/comments/waline.pug b/layout/includes/third-party/comments/waline.pug index 027a312..b1d3eb1 100644 --- a/layout/includes/third-party/comments/waline.pug +++ b/layout/includes/third-party/comments/waline.pug @@ -13,6 +13,7 @@ script. path: location.pathname, emojiCDN: '#{theme.waline.emojiCDN}', emojiMaps: !{emojiMaps}, + visitor: #{theme.waline.visitor} } if (!{Boolean(option)}) { diff --git a/layout/includes/widget/card_author.pug b/layout/includes/widget/card_author.pug index 933b7ce..1bbc47d 100644 --- a/layout/includes/widget/card_author.pug +++ b/layout/includes/widget/card_author.pug @@ -1,10 +1,11 @@ if theme.aside.card_author.enable .card-widget.card-info .card-info-avatar.is-center - if theme.lazyload.enable - img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar") - else - img.avatar-img(src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar") + if theme.avatar.img + if theme.lazyload.enable + img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar") + else + img.avatar-img(src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar") .author-info__name= config.author .author-info__description!= theme.aside.card_author.description || config.description diff --git a/layout/includes/widget/card_tags.pug b/layout/includes/widget/card_tags.pug index 2293d82..de40e90 100644 --- a/layout/includes/widget/card_tags.pug +++ b/layout/includes/widget/card_tags.pug @@ -7,6 +7,6 @@ if theme.aside.card_tags.enable - let tagLimit = theme.aside.card_tags.limit === 0 ? 0 : theme.aside.card_tags.limit || 40 if theme.aside.card_tags.color - .card-tag-cloud!= cloudTags({source: site.tags, minfontsize: 1.1, maxfontsize: 1.5, limit: tagLimit, unit: 'em'}) + .card-tag-cloud!= cloudTags({source: site.tags, minfontsize: 1.15, maxfontsize: 1.45, limit: tagLimit, unit: 'em'}) else .card-tag-cloud!= tagcloud({min_font: 1.1, max_font: 1.5, amount: tagLimit , color: true, start_color: '#999', end_color: '#99a9bf', unit: 'em'}) diff --git a/package.json b/package.json index 0b419cf..f18ac78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "3.7.0-b2", + "version": "3.7.0-b3", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/scripts/filters/random_cover.js b/scripts/filters/random_cover.js index 8455d60..827059f 100644 --- a/scripts/filters/random_cover.js +++ b/scripts/filters/random_cover.js @@ -39,7 +39,7 @@ function randomCover () { return cover } } else { - cover = 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg' + cover = theme.default_top_img || 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg' return cover } } diff --git a/source/css/_layout/aside.styl b/source/css/_layout/aside.styl index cee1701..6198f62 100644 --- a/source/css/_layout/aside.styl +++ b/source/css/_layout/aside.styl @@ -115,7 +115,7 @@ .card-tag-cloud a display: inline-block - padding: 0 .1rem + padding: 0 .2rem &:hover color: $text-hover !important