mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-23 10:58:13 +08:00
fix(theme): incorrect auto sidebar sorting (#399)
This commit is contained in:
parent
ef113f7df7
commit
0b7a955343
@ -95,7 +95,7 @@ function fileSorting(filepath?: string): number | false {
|
||||
const matched = filepath.match(RE_FILE_SORTING)
|
||||
const sorted = matched ? Number(matched[1]) : 0
|
||||
if (Number.isNaN(sorted))
|
||||
return 0
|
||||
return Number.MAX_SAFE_INTEGER
|
||||
return sorted
|
||||
}
|
||||
|
||||
@ -109,11 +109,9 @@ function getAutoDirSidebar(
|
||||
.map((page) => {
|
||||
return { ...page, splitPath: page.data.filePathRelative?.split('/') || [] }
|
||||
})
|
||||
|
||||
const maxIndex = Math.max(...pages.map(page => page.splitPath.length))
|
||||
let nowIndex = 0
|
||||
|
||||
while (nowIndex < maxIndex) {
|
||||
let nowIndex = maxIndex - 1
|
||||
while (nowIndex >= 0) {
|
||||
pages = pages.sort((prev, next) => {
|
||||
const pi = fileSorting(prev.splitPath?.[nowIndex])
|
||||
const ni = fileSorting(next.splitPath?.[nowIndex])
|
||||
@ -124,7 +122,7 @@ function getAutoDirSidebar(
|
||||
return pi < ni ? -1 : 1
|
||||
})
|
||||
|
||||
nowIndex++
|
||||
nowIndex--
|
||||
}
|
||||
|
||||
const RE_INDEX = ['index.md', 'README.md', 'readme.md']
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user