mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-08-08 11:38:42 +08:00
- Add :not([data-fancybox]) to pjaxExclude to prevent fancybox links from being loaded via pjax - Refactor series grouping to use a shared hexo._seriesGroups object built once - Improve performance by avoiding repeated post iteration in both tag and helper - Version bump to 5.6.1
25 lines
778 B
JavaScript
25 lines
778 B
JavaScript
'use strict'
|
|
|
|
// Read pre-built groups from tag/series.js (hexo._seriesGroups)
|
|
// and sort each group according to the sidebar card config.
|
|
hexo.extend.helper.register('groupPosts', function () {
|
|
const groups = hexo._seriesGroups || {}
|
|
const { orderBy = 'date', order = 1 } = this.theme.aside.card_post_series
|
|
|
|
const result = {}
|
|
Object.keys(groups).forEach(key => {
|
|
const arr = groups[key].slice() // copy to avoid mutating the shared data
|
|
if (orderBy === 'title') {
|
|
arr.sort((a, b) => {
|
|
const cmp = a.title.toUpperCase().localeCompare(b.title.toUpperCase())
|
|
return order === 1 ? cmp : -cmp
|
|
})
|
|
} else {
|
|
arr.sort((a, b) => order === 1 ? a.date - b.date : b.date - a.date)
|
|
}
|
|
result[key] = arr
|
|
})
|
|
|
|
return result
|
|
})
|