mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-10-03 22:22:00 +08:00
fix: exclude fancybox links from pjax and refactor series logic
- 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
This commit is contained in:
1 parent
d8942c236a
commit
77ec898737
4 files changed
+67
-44
No files matched your search
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
- var pjaxExclude = 'a:not([target="_blank"])'
|
||||
- var pjaxExclude = 'a:not([target="_blank"]):not([data-fancybox])'
|
||||
if theme.pjax.exclude
|
||||
each val in theme.pjax.exclude
|
||||
- pjaxExclude += `:not([href="${val}"])`
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hexo-theme-butterfly",
|
||||
"version": "5.6.0",
|
||||
"version": "5.6.1",
|
||||
"description": "A Simple and Card UI Design theme for Hexo",
|
||||
"main": "package.json",
|
||||
"scripts": {
|
||||
|
||||
+18
-16
@@ -1,22 +1,24 @@
|
||||
'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 getGroupArray = array => {
|
||||
return array.reduce((groups, item) => {
|
||||
const key = item.series
|
||||
if (key) {
|
||||
groups[key] = groups[key] || []
|
||||
groups[key].push(item)
|
||||
}
|
||||
return groups
|
||||
}, {})
|
||||
}
|
||||
|
||||
const sortPosts = posts => {
|
||||
const groups = hexo._seriesGroups || {}
|
||||
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))
|
||||
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
|
||||
})
|
||||
Loaded 3 of 4 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user