mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-16 15:09:28 +00:00
hotfix-gitbook
This commit is contained in:
@@ -17,19 +17,19 @@ const NavPostList = (props) => {
|
||||
const groupedArray = filteredNavPages?.reduce((groups, item) => {
|
||||
const categoryName = item?.category ? item?.category : '' // 将category转换为字符串
|
||||
|
||||
let existingGroup = null
|
||||
// 开启自动分组排序
|
||||
if (JSON.parse(CONFIG.AUTO_SORT)) {
|
||||
const existingGroup = groups.find(group => group.category === categoryName)
|
||||
if (existingGroup) {
|
||||
existingGroup.items.push(item)
|
||||
} else {
|
||||
groups.push({ category: categoryName, items: [item] })
|
||||
}
|
||||
existingGroup = groups.find(group => group.category === categoryName) // 搜索同名的最后一个分组
|
||||
} else {
|
||||
const lastGroup = groups[groups.length - 1] // 获取最后一个分组
|
||||
if (!lastGroup || lastGroup?.category !== categoryName) { // 如果当前元素的category与上一个元素不同,则创建新分组
|
||||
groups.push({ category: categoryName, items: [] })
|
||||
}
|
||||
existingGroup = groups[groups.length - 1] // 获取最后一个分组
|
||||
}
|
||||
|
||||
// 添加数据
|
||||
if (existingGroup && existingGroup.category === categoryName) {
|
||||
existingGroup.items.push(item)
|
||||
} else {
|
||||
groups.push({ category: categoryName, items: [item] })
|
||||
}
|
||||
return groups
|
||||
}, [])
|
||||
|
||||
Reference in New Issue
Block a user