Skip to content

Commit

Permalink
gitbook
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Jul 30, 2023
1 parent 5cce8c5 commit 386edbd
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions themes/gitbook/components/PageNavDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,6 @@ const PageNavDrawer = (props) => {
const { pageNavVisible, changePageNavVisible } = useGitBookGlobal()
const { filteredNavPages } = props

const groupedArray = filteredNavPages?.reduce((groups, item) => {
const categoryName = item?.category ? item?.category : '' // 将category转换为字符串
const lastGroup = groups[groups.length - 1] // 获取最后一个分组

if (!lastGroup || lastGroup?.category !== categoryName) { // 如果当前元素的category与上一个元素不同,则创建新分组
groups.push({ category: categoryName, items: [] })
}

groups[groups.length - 1].items.push(item) // 将元素加入对应的分组

return groups
}, [])

const switchVisible = () => {
changePageNavVisible(!pageNavVisible)
}
Expand All @@ -37,7 +24,7 @@ const PageNavDrawer = (props) => {
' overflow-y-hidden shadow-card w-72 duration-200 fixed left-1 top-16 rounded py-2 bg-white dark:bg-gray-600'}>
<div className='dark:text-gray-400 text-gray-600 h-96 overflow-y-scroll p-3'>
{/* 所有文章列表 */}
<NavPostList groupedArray={groupedArray} />
<NavPostList filteredNavPages={filteredNavPages} />
</div>
</div>
</div>
Expand Down

0 comments on commit 386edbd

Please sign in to comment.