Hexo个人博客
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
573 B

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