hotfix-gitbook

This commit is contained in:
tangly1024.com
2023-08-15 14:32:36 +08:00
parent cad975f812
commit 454c85f313

View File

@@ -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
}, [])