mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-17 04:40:53 +08:00
feat: 置頂圖標改為在標題左側 feat: 可配置打賞按鈕的文字 feat: 側邊欄增加 系列文章顯示 feat: 增加 series 系列文章 標籤外掛 feat: 移除 addthis 分享 improvement: 代碼優化 improvement: tabs 標籤外掛的回到頂部箭頭位置調整 improvement: 更新 plugin.yml
23 lines
573 B
JavaScript
23 lines
573 B
JavaScript
'use strict'
|
|
|
|
hexo.extend.helper.register('groupPosts', function () {
|
|
const getGroupArray = array => {
|
|
const groups = {}
|
|
array.forEach(item => {
|
|
const Key = item.series
|
|
if (!Key) return
|
|
groups[Key] = groups[Key] || []
|
|
groups[Key].push(item)
|
|
})
|
|
return groups
|
|
}
|
|
|
|
const sortPosts = posts => {
|
|
const { orderBy = 'date', order = 1 } = this.theme.aside.card_post_series
|
|
if (orderBy === 'title') return posts.sort('title', order)
|
|
return posts.sort('date', order)
|
|
}
|
|
|
|
return getGroupArray(sortPosts(this.site.posts))
|
|
})
|