feat: 添加waline,valine 和twikoo 提供的文章閲讀數配置 close #502

improvement: 當文章頁cover 和cover 的 default_img都沒有配置時,會去讀取default_top_img的參數
improvement: 在完全沒有配置的情況下,運行時控制臺報null 的問題
This commit is contained in:
Jerry
2021-02-19 22:14:34 +08:00
parent 0cea722da8
commit b176ff0fa7
12 changed files with 41 additions and 20 deletions

View File

@@ -321,6 +321,7 @@ valine:
emojiCDN: # emoji CDN emojiCDN: # emoji CDN
enableQQ: false # enable the Nickname box to automatically get QQ Nickname and QQ Avatar enableQQ: false # enable the Nickname box to automatically get QQ Nickname and QQ Avatar
requiredFields: nick,mail # required fields (nick/mail) requiredFields: nick,mail # required fields (nick/mail)
visitor: false
option: option:
# waline - A simple comment system with backend support fork from Valine # 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 avatar: monsterid # gravatar style https://zh-tw.gravatar.com/site/implement/images/#default-image
emojiCDN: # emoji CDN emojiCDN: # emoji CDN
bg: # waline background bg: # waline background
visitor: false
option: option:
# utterances # utterances
@@ -356,6 +358,7 @@ facebook_comments:
twikoo: twikoo:
envId: envId:
region: region:
visitor: false
option: option:
# Chat Services # Chat Services

View File

@@ -1,6 +1,6 @@
if theme.Open_Graph_meta if theme.Open_Graph_meta
- let contentType = is_post() ? 'article' : 'website' - 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_appId = theme.facebook_comments.app_id || ''
- let fb_admins = theme.facebook_comments.user_id || '' - let fb_admins = theme.facebook_comments.user_id || ''

View File

@@ -1,6 +1,6 @@
if !theme.disable_top_img && page.top_img !== false if !theme.disable_top_img && page.top_img !== false
if is_post() 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() else if is_page()
- var top_img = page.top_img || theme.default_top_img - var top_img = page.top_img || theme.default_top_img
else if is_tag() else if is_tag()

View File

@@ -1,3 +1,4 @@
- let comments = theme.comments
#post-info #post-info
h1.post-title= page.title || _p('no_title') h1.post-title= page.title || _p('no_title')
if theme.post_edit.enable if theme.post_edit.enable
@@ -51,15 +52,28 @@
span.post-meta-label= _p('post.min2read') + ':' span.post-meta-label= _p('post.min2read') + ':'
span= min2read(page.content, {cn: 350, en: 160}) + _p('post.min2read_unit') 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-separator |
span.post-meta-pv-cv span(class=parent_class id=parent_id)
i.far.fa-eye.fa-fw.post-meta-icon i.far.fa-eye.fa-fw.post-meta-icon
span.post-meta-label=_p('post.page_pv') + ':' 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 if theme.busuanzi.page_pv
- var whichCount = theme.comments.use[0] +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 mixin countBlock
span.post-meta-separator | span.post-meta-separator |

View File

@@ -1,11 +1,12 @@
#sidebar #sidebar
#menu-mask #menu-mask
#sidebar-menus #sidebar-menus
.author-avatar if theme.avatar.img
if theme.lazyload.enable .author-avatar
img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar") if theme.lazyload.enable
else img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar")
img.avatar-img(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 .site-data
if site.posts.length if site.posts.length
.data-item.is-center .data-item.is-center

View File

@@ -21,6 +21,7 @@ script.
emojiMaps: !{emojiMaps}, emojiMaps: !{emojiMaps},
enableQQ: #{theme.valine.enableQQ}, enableQQ: #{theme.valine.enableQQ},
path: window.location.pathname, path: window.location.pathname,
visitor: #{theme.valine.visitor}
} }
if (!{Boolean(theme.valine.requiredFields)}) { if (!{Boolean(theme.valine.requiredFields)}) {

View File

@@ -13,6 +13,7 @@ script.
path: location.pathname, path: location.pathname,
emojiCDN: '#{theme.waline.emojiCDN}', emojiCDN: '#{theme.waline.emojiCDN}',
emojiMaps: !{emojiMaps}, emojiMaps: !{emojiMaps},
visitor: #{theme.waline.visitor}
} }
if (!{Boolean(option)}) { if (!{Boolean(option)}) {

View File

@@ -1,10 +1,11 @@
if theme.aside.card_author.enable if theme.aside.card_author.enable
.card-widget.card-info .card-widget.card-info
.card-info-avatar.is-center .card-info-avatar.is-center
if theme.lazyload.enable if theme.avatar.img
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") if theme.lazyload.enable
else 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")
img.avatar-img(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__name= config.author
.author-info__description!= theme.aside.card_author.description || config.description .author-info__description!= theme.aside.card_author.description || config.description

View File

@@ -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 - let tagLimit = theme.aside.card_tags.limit === 0 ? 0 : theme.aside.card_tags.limit || 40
if theme.aside.card_tags.color 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 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'}) .card-tag-cloud!= tagcloud({min_font: 1.1, max_font: 1.5, amount: tagLimit , color: true, start_color: '#999', end_color: '#99a9bf', unit: 'em'})

View File

@@ -1,6 +1,6 @@
{ {
"name": "hexo-theme-butterfly", "name": "hexo-theme-butterfly",
"version": "3.7.0-b2", "version": "3.7.0-b3",
"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": {

View File

@@ -39,7 +39,7 @@ function randomCover () {
return cover return cover
} }
} else { } 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 return cover
} }
} }

View File

@@ -115,7 +115,7 @@
.card-tag-cloud .card-tag-cloud
a a
display: inline-block display: inline-block
padding: 0 .1rem padding: 0 .2rem
&:hover &:hover
color: $text-hover !important color: $text-hover !important