mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
breaking changes: archives 隱藏 aside 設置更改
feat: tag 和 category 頁面可設置隱藏 aside feat: 子歸檔頁面顯示的文章數量不再顯示總文章數量,而是對應的子歸檔文章數量 feat: 為一些數據加載增加 loading 顯示 improvement: 修改 note 圖標 class 名字,避免第三方圖標覆蓋主題樣式
This commit is contained in:
@@ -628,7 +628,10 @@ aside:
|
|||||||
button: true
|
button: true
|
||||||
mobile: true # display on mobile
|
mobile: true # display on mobile
|
||||||
position: right # left or right
|
position: right # left or right
|
||||||
archives: true
|
display:
|
||||||
|
archive: true
|
||||||
|
tag: true
|
||||||
|
category: true
|
||||||
card_author:
|
card_author:
|
||||||
enable: true
|
enable: true
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ extends includes/layout.pug
|
|||||||
block content
|
block content
|
||||||
include ./includes/mixins/article-sort.pug
|
include ./includes/mixins/article-sort.pug
|
||||||
#archive
|
#archive
|
||||||
.article-sort-title= _p('page.articles') + ' - ' + site.posts.length
|
- const archiveLength = findArchiveLength(fragment_cache)
|
||||||
|
.article-sort-title= _p('page.articles') + ' - ' + archiveLength
|
||||||
+articleSort(page.posts)
|
+articleSort(page.posts)
|
||||||
include includes/pagination.pug
|
include includes/pagination.pug
|
||||||
@@ -66,18 +66,23 @@
|
|||||||
if commentUse[0] === 'Valine' && theme.valine.visitor
|
if commentUse[0] === 'Valine' && theme.valine.visitor
|
||||||
+pvBlock(url_for(page.path),'leancloud_visitors',page.title)
|
+pvBlock(url_for(page.path),'leancloud_visitors',page.title)
|
||||||
span.leancloud-visitors-count
|
span.leancloud-visitors-count
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
else if commentUse[0] === 'Waline' && theme.waline.pageview
|
else if commentUse[0] === 'Waline' && theme.waline.pageview
|
||||||
+pvBlock('','','')
|
+pvBlock('','','')
|
||||||
span.waline-pageview-count(data-path=url_for(page.path))
|
span.waline-pageview-count(data-path=url_for(page.path))
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
else if commentUse[0] === 'Twikoo' && theme.twikoo.visitor
|
else if commentUse[0] === 'Twikoo' && theme.twikoo.visitor
|
||||||
+pvBlock('','','')
|
+pvBlock('','','')
|
||||||
span#twikoo_visitors
|
span#twikoo_visitors
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
else if theme.busuanzi.page_pv
|
else if theme.busuanzi.page_pv
|
||||||
+pvBlock('','post-meta-pv-cv','')
|
+pvBlock('','post-meta-pv-cv','')
|
||||||
span#busuanzi_value_page_pv
|
span#busuanzi_value_page_pv
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
else if theme.busuanzi.page_pv
|
else if theme.busuanzi.page_pv
|
||||||
+pvBlock('','post-meta-pv-cv','')
|
+pvBlock('','post-meta-pv-cv','')
|
||||||
span#busuanzi_value_page_pv
|
span#busuanzi_value_page_pv
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
|
|
||||||
if comments.count && !comments.lazyload && page.comments !== false && comments.use
|
if comments.count && !comments.lazyload && page.comments !== false && comments.use
|
||||||
- var whichCount = comments.use[0]
|
- var whichCount = comments.use[0]
|
||||||
@@ -95,31 +100,39 @@
|
|||||||
+countBlock
|
+countBlock
|
||||||
span.disqus-comment-count
|
span.disqus-comment-count
|
||||||
a(href=full_url_for(page.path) + '#disqus_thread')
|
a(href=full_url_for(page.path) + '#disqus_thread')
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Disqusjs'
|
when 'Disqusjs'
|
||||||
+countBlock
|
+countBlock
|
||||||
a(href=full_url_for(page.path) + '#disqusjs')
|
a(href=full_url_for(page.path) + '#disqusjs')
|
||||||
span.disqus-comment-count(data-disqus-url=full_url_for(page.path))
|
span.disqus-comment-count(data-disqus-url=full_url_for(page.path))
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Valine'
|
when 'Valine'
|
||||||
+countBlock
|
+countBlock
|
||||||
a(href=url_for(page.path) + '#post-comment' itemprop="discussionUrl")
|
a(href=url_for(page.path) + '#post-comment' itemprop="discussionUrl")
|
||||||
span.valine-comment-count(data-xid=url_for(page.path) itemprop="commentCount")
|
span.valine-comment-count(data-xid=url_for(page.path) itemprop="commentCount")
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Waline'
|
when 'Waline'
|
||||||
+countBlock
|
+countBlock
|
||||||
a(href=url_for(page.path) + '#post-comment')
|
a(href=url_for(page.path) + '#post-comment')
|
||||||
span.waline-comment-count(data-path=url_for(page.path))
|
span.waline-comment-count(data-path=url_for(page.path))
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Gitalk'
|
when 'Gitalk'
|
||||||
+countBlock
|
+countBlock
|
||||||
a(href=url_for(page.path) + '#post-comment')
|
a(href=url_for(page.path) + '#post-comment')
|
||||||
span.gitalk-comment-count
|
span.gitalk-comment-count
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Twikoo'
|
when 'Twikoo'
|
||||||
+countBlock
|
+countBlock
|
||||||
a(href=url_for(page.path) + '#post-comment')
|
a(href=url_for(page.path) + '#post-comment')
|
||||||
span#twikoo-count
|
span#twikoo-count
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Facebook Comments'
|
when 'Facebook Comments'
|
||||||
+countBlock
|
+countBlock
|
||||||
a(href=url_for(page.path) + '#post-comment')
|
a(href=url_for(page.path) + '#post-comment')
|
||||||
span.fb-comments-count(data-href=urlNoIndex())
|
span.fb-comments-count(data-href=urlNoIndex())
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Remark42'
|
when 'Remark42'
|
||||||
+countBlock
|
+countBlock
|
||||||
a(href=url_for(page.path) + '#post-comment')
|
a(href=url_for(page.path) + '#post-comment')
|
||||||
span.remark42__counter(data-url=urlNoIndex())
|
span.remark42__counter(data-url=urlNoIndex())
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
- var htmlClassHideAside = theme.aside.enable && theme.aside.hide ? 'hide-aside' : ''
|
- var htmlClassHideAside = theme.aside.enable && theme.aside.hide ? 'hide-aside' : ''
|
||||||
- page.aside = is_archive() ? theme.aside.archives : page.aside
|
- page.aside = is_archive() ? theme.aside.display.archive: is_category() ? theme.aside.display.category : is_tag() ? theme.aside.display.tag : page.aside
|
||||||
- var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : ''
|
- var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : ''
|
||||||
- var pageType = is_post() ? 'post' : 'page'
|
- var pageType = is_post() ? 'post' : 'page'
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ mixin postUI(posts)
|
|||||||
let link = article.link || article.path
|
let link = article.link || article.path
|
||||||
let title = article.title || _p('no_title')
|
let title = article.title || _p('no_title')
|
||||||
const position = theme.cover.position
|
const position = theme.cover.position
|
||||||
let leftOrRight = position === 'both'
|
let leftOrRight = position === 'both'
|
||||||
? index%2 == 0 ? 'left' : 'right'
|
? index%2 == 0 ? 'left' : 'right'
|
||||||
: position === 'left' ? 'left' : 'right'
|
: position === 'left' ? 'left' : 'right'
|
||||||
let post_cover = article.cover
|
let post_cover = article.cover
|
||||||
@@ -72,29 +72,36 @@ mixin postUI(posts)
|
|||||||
when 'Disqus'
|
when 'Disqus'
|
||||||
+countBlockInIndex
|
+countBlockInIndex
|
||||||
a(href=full_url_for(link) + '#disqus_thread')
|
a(href=full_url_for(link) + '#disqus_thread')
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Disqusjs'
|
when 'Disqusjs'
|
||||||
+countBlockInIndex
|
+countBlockInIndex
|
||||||
a(href=full_url_for(link) + '#disqusjs')
|
a(href=full_url_for(link) + '#disqusjs')
|
||||||
span.disqus-comment-count(data-disqus-url=full_url_for(link))
|
span.disqus-comment-count(data-disqus-url=full_url_for(link))
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Valine'
|
when 'Valine'
|
||||||
+countBlockInIndex
|
+countBlockInIndex
|
||||||
a(href=url_for(link) + '#post-comment')
|
a(href=url_for(link) + '#post-comment')
|
||||||
span.valine-comment-count(data-xid=url_for(link))
|
span.valine-comment-count(data-xid=url_for(link))
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Waline'
|
when 'Waline'
|
||||||
+countBlockInIndex
|
+countBlockInIndex
|
||||||
a(href=url_for(link) + '#post-comment')
|
a(href=url_for(link) + '#post-comment')
|
||||||
span.waline-comment-count(id=url_for(link))
|
span.waline-comment-count(id=url_for(link))
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Twikoo'
|
when 'Twikoo'
|
||||||
+countBlockInIndex
|
+countBlockInIndex
|
||||||
a.twikoo-count(href=url_for(link) + '#post-comment')
|
a.twikoo-count(href=url_for(link) + '#post-comment')
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Facebook Comments'
|
when 'Facebook Comments'
|
||||||
+countBlockInIndex
|
+countBlockInIndex
|
||||||
a(href=url_for(link) + '#post-comment')
|
a(href=url_for(link) + '#post-comment')
|
||||||
span.fb-comments-count(data-href=urlNoIndex(article.permalink))
|
span.fb-comments-count(data-href=urlNoIndex(article.permalink))
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Remark42'
|
when 'Remark42'
|
||||||
+countBlockInIndex
|
+countBlockInIndex
|
||||||
a(href=url_for(link) + '#post-comment')
|
a(href=url_for(link) + '#post-comment')
|
||||||
span.remark42__counter(data-url=urlNoIndex(article.permalink))
|
span.remark42__counter(data-url=urlNoIndex(article.permalink))
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
|
|
||||||
//- Display the article introduction on homepage
|
//- Display the article introduction on homepage
|
||||||
case theme.index_post_content.method
|
case theme.index_post_content.method
|
||||||
|
|||||||
@@ -12,20 +12,24 @@ if theme.aside.card_webinfo.enable
|
|||||||
.webinfo-item
|
.webinfo-item
|
||||||
.item-name= _p('aside.card_webinfo.runtime.name') + " :"
|
.item-name= _p('aside.card_webinfo.runtime.name') + " :"
|
||||||
.item-count#runtimeshow(data-publishDate=date_xml(theme.runtimeshow.publish_date))
|
.item-count#runtimeshow(data-publishDate=date_xml(theme.runtimeshow.publish_date))
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
if theme.wordcount.enable && theme.wordcount.total_wordcount
|
if theme.wordcount.enable && theme.wordcount.total_wordcount
|
||||||
.webinfo-item
|
.webinfo-item
|
||||||
.item-name=_p('aside.card_webinfo.site_wordcount') + " :"
|
.item-name=_p('aside.card_webinfo.site_wordcount') + " :"
|
||||||
.item-count=totalcount(site)
|
.item-count=totalcount(site)
|
||||||
if theme.busuanzi.site_uv
|
if theme.busuanzi.site_uv
|
||||||
.webinfo-item
|
.webinfo-item
|
||||||
.item-name= _p('aside.card_webinfo.site_uv_name') + " :"
|
.item-name= _p('aside.card_webinfo.site_uv_name') + " :"
|
||||||
.item-count#busuanzi_value_site_uv
|
.item-count#busuanzi_value_site_uv
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
if theme.busuanzi.site_pv
|
if theme.busuanzi.site_pv
|
||||||
.webinfo-item
|
.webinfo-item
|
||||||
.item-name= _p('aside.card_webinfo.site_pv_name') + " :"
|
.item-name= _p('aside.card_webinfo.site_pv_name') + " :"
|
||||||
.item-count#busuanzi_value_site_pv
|
.item-count#busuanzi_value_site_pv
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
if theme.aside.card_webinfo.last_push_date
|
if theme.aside.card_webinfo.last_push_date
|
||||||
.webinfo-item
|
.webinfo-item
|
||||||
.item-name= _p('aside.card_webinfo.last_push_date.name') + " :"
|
.item-name= _p('aside.card_webinfo.last_push_date.name') + " :"
|
||||||
.item-count#last-push-date(data-lastPushDate=date_xml(Date.now()))
|
.item-count#last-push-date(data-lastPushDate=date_xml(Date.now()))
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hexo-theme-butterfly",
|
"name": "hexo-theme-butterfly",
|
||||||
"version": "4.3.0-b3",
|
"version": "4.3.0-b4",
|
||||||
"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": {
|
||||||
|
|||||||
16
plugins.yml
16
plugins.yml
@@ -5,7 +5,7 @@ algolia_search_v4:
|
|||||||
instantsearch_v4:
|
instantsearch_v4:
|
||||||
name: instantsearch.js
|
name: instantsearch.js
|
||||||
file: dist/instantsearch.production.min.js
|
file: dist/instantsearch.production.min.js
|
||||||
version: 4.41.0
|
version: 4.41.2
|
||||||
pjax:
|
pjax:
|
||||||
name: pjax
|
name: pjax
|
||||||
file: pjax.min.js
|
file: pjax.min.js
|
||||||
@@ -42,12 +42,12 @@ waline_js:
|
|||||||
name: '@waline/client'
|
name: '@waline/client'
|
||||||
file: dist/waline.js
|
file: dist/waline.js
|
||||||
other_name: waline
|
other_name: waline
|
||||||
version: 2.5.1
|
version: 2.6.1
|
||||||
waline_css:
|
waline_css:
|
||||||
name: '@waline/client'
|
name: '@waline/client'
|
||||||
file: dist/waline.css
|
file: dist/waline.css
|
||||||
other_name: waline
|
other_name: waline
|
||||||
version: 2.5.1
|
version: 2.6.1
|
||||||
sharejs:
|
sharejs:
|
||||||
name: butterfly-extsrc
|
name: butterfly-extsrc
|
||||||
file: sharejs/dist/js/social-share.min.js
|
file: sharejs/dist/js/social-share.min.js
|
||||||
@@ -73,7 +73,7 @@ katex_copytex:
|
|||||||
mermaid:
|
mermaid:
|
||||||
name: mermaid
|
name: mermaid
|
||||||
file: dist/mermaid.min.js
|
file: dist/mermaid.min.js
|
||||||
version: 9.1.1
|
version: 9.1.2
|
||||||
canvas_ribbon:
|
canvas_ribbon:
|
||||||
name: butterfly-extsrc
|
name: butterfly-extsrc
|
||||||
file: dist/canvas-ribbon.min.js
|
file: dist/canvas-ribbon.min.js
|
||||||
@@ -122,10 +122,12 @@ fancybox_css_v4:
|
|||||||
name: '@fancyapps/ui'
|
name: '@fancyapps/ui'
|
||||||
file: dist/fancybox.css
|
file: dist/fancybox.css
|
||||||
version: 4.0.27
|
version: 4.0.27
|
||||||
|
other_name: fancyapps-ui
|
||||||
fancybox_v4:
|
fancybox_v4:
|
||||||
name: '@fancyapps/ui'
|
name: '@fancyapps/ui'
|
||||||
file: dist/fancybox.umd.js
|
file: dist/fancybox.umd.js
|
||||||
version: 4.0.27
|
version: 4.0.27
|
||||||
|
other_name: fancyapps-ui
|
||||||
medium_zoom:
|
medium_zoom:
|
||||||
name: medium-zoom
|
name: medium-zoom
|
||||||
file: dist/medium-zoom.min.js
|
file: dist/medium-zoom.min.js
|
||||||
@@ -146,11 +148,11 @@ fontawesomeV6:
|
|||||||
flickr_justified_gallery_js:
|
flickr_justified_gallery_js:
|
||||||
name: flickr-justified-gallery
|
name: flickr-justified-gallery
|
||||||
file: dist/fjGallery.min.js
|
file: dist/fjGallery.min.js
|
||||||
version: 2.0.0
|
version: 2.1.2
|
||||||
flickr_justified_gallery_css:
|
flickr_justified_gallery_css:
|
||||||
name: flickr-justified-gallery
|
name: flickr-justified-gallery
|
||||||
file: dist/fjGallery.css
|
file: dist/fjGallery.css
|
||||||
version: 2.0.0
|
version: 2.1.2
|
||||||
aplayer_css:
|
aplayer_css:
|
||||||
name: aplayer
|
name: aplayer
|
||||||
file: dist/APlayer.min.css
|
file: dist/APlayer.min.css
|
||||||
@@ -177,4 +179,4 @@ prismjs_autoloader:
|
|||||||
name: prismjs
|
name: prismjs
|
||||||
file: plugins/autoloader/prism-autoloader.min.js
|
file: plugins/autoloader/prism-autoloader.min.js
|
||||||
other_name: prism
|
other_name: prism
|
||||||
version: 1.28.0
|
version: 1.28.0
|
||||||
58
scripts/helpers/findArchiveLength.js
Normal file
58
scripts/helpers/findArchiveLength.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
hexo.extend.helper.register('findArchiveLength', function (func) {
|
||||||
|
const allPostsLength = this.site.posts.length;
|
||||||
|
if (hexo.config.archive_generator && hexo.config.archive_generator.enable === false ) return allPostsLength
|
||||||
|
const { yearly, monthly, daily } = hexo.config.archive_generator
|
||||||
|
const { year, month, day } = this.page
|
||||||
|
if (yearly === false || !year) return allPostsLength
|
||||||
|
|
||||||
|
const posts = this.site.posts.sort('date')
|
||||||
|
|
||||||
|
const compareFunc = (type,y1,m1,d1,y2,m2,d2) => {
|
||||||
|
if (type === 'year') {
|
||||||
|
return y1 === y2
|
||||||
|
} else if (type === 'month') {
|
||||||
|
return y1 === y2 && m1 === m2
|
||||||
|
} else if (type === 'day') {
|
||||||
|
return y1 === y2 && m1 === m2 && d1 === d2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const generateDateObj = (type) => {
|
||||||
|
let dateObj = []
|
||||||
|
let length = 0
|
||||||
|
|
||||||
|
posts.forEach(post => {
|
||||||
|
let date = post.date.clone()
|
||||||
|
const year = date.year()
|
||||||
|
const month = date.month() + 1
|
||||||
|
const day = date.date()
|
||||||
|
let lastData = dateObj[length - 1]
|
||||||
|
|
||||||
|
if (!lastData || !compareFunc(type, lastData.year, lastData.month, lastData.day, year, month, day)) {
|
||||||
|
const name = type === 'year' ? year : type === 'month' ? `${year}-${month}` : `${year}-${month}-${day}`
|
||||||
|
length = dateObj.push({
|
||||||
|
name,
|
||||||
|
year,
|
||||||
|
month,
|
||||||
|
day,
|
||||||
|
count: 1
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
lastData.count++
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return dateObj
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = func('createArchiveObj', ()=> {
|
||||||
|
const yearObj = yearly ? generateDateObj('year') : []
|
||||||
|
const monthObj = monthly ? generateDateObj('month') : []
|
||||||
|
const dayObj = daily ? generateDateObj('day') : []
|
||||||
|
const fullObj = [...yearObj, ...monthObj, ...dayObj]
|
||||||
|
return fullObj
|
||||||
|
})
|
||||||
|
|
||||||
|
const name = month ? day ? `${year}-${month}-${day}` : `${year}-${month}` : year
|
||||||
|
return data.find(item => item.name === name).count
|
||||||
|
})
|
||||||
@@ -17,7 +17,7 @@ function postNote (args, content) {
|
|||||||
const iconArray = args[args.length - 2]
|
const iconArray = args[args.length - 2]
|
||||||
if (iconArray && iconArray.startsWith('fa')) {
|
if (iconArray && iconArray.startsWith('fa')) {
|
||||||
icon = `<i class="note-icon ${iconArray}"></i>`
|
icon = `<i class="note-icon ${iconArray}"></i>`
|
||||||
args[args.length - 2] = 'icon'
|
args[args.length - 2] = 'icon-padding'
|
||||||
}
|
}
|
||||||
|
|
||||||
return `<div class="note ${args.join(' ')}">${icon + hexo.render.renderSync({ text: content, engine: 'markdown' })}</div>`
|
return `<div class="note ${args.join(' ')}">${icon + hexo.render.renderSync({ text: content, engine: 'markdown' })}</div>`
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
if hexo-config('note.border_radius') is a 'unit'
|
if hexo-config('note.border_radius') is a 'unit'
|
||||||
border-radius: unit(hexo-config('note.border_radius'), px)
|
border-radius: unit(hexo-config('note.border_radius'), px)
|
||||||
|
|
||||||
&.icon
|
&.icon-padding
|
||||||
padding-left: 3em
|
padding-left: 3em
|
||||||
|
|
||||||
& > .note-icon
|
& > .note-icon
|
||||||
|
|||||||
Reference in New Issue
Block a user