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
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

View File

@ -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 || ''

View File

@ -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()

View File

@ -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 |

View File

@ -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

View File

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

View File

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

View File

@ -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

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
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'})

View File

@ -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": {

View File

@ -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
}
}

View File

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