Skip to content

Commit

Permalink
fix(theme): incorrect resolve page path when sidebar matched
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhanbo committed Aug 30, 2024
1 parent 2443f99 commit 03b645e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions theme/src/client/composables/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export function getSidebar(routePath: string, routeLocal: string): ResolvedSideb
return resolveSidebarItems(_sidebar, routeLocal)
}
else if (isPlainObject(_sidebar)) {
routePath = decodeURIComponent(routePath)
const dir
= Object.keys(_sidebar)
.sort((a, b) => b.split('/').length - a.split('/').length)
Expand Down
4 changes: 2 additions & 2 deletions theme/src/node/prepare/prepareSidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ function getAutoDirSidebar(

while (nowIndex < maxIndex) {
pages = pages.sort((prev, next) => {
const pi = prev.splitPath?.[nowIndex]?.match(/(\d+)\.(?=[^/]+$)/)?.[1]
const ni = next.splitPath?.[nowIndex]?.match(/(\d+)\.(?=[^/]+$)/)?.[1]
const pi = prev.splitPath?.[nowIndex]?.match(/(?:(\d+)\.)?(?=[^/]+$)/)?.[1]
const ni = next.splitPath?.[nowIndex]?.match(/(?:(\d+)\.)?(?=[^/]+$)/)?.[1]
if (!pi || !ni)
return 0
return Number.parseFloat(pi) < Number.parseFloat(ni) ? -1 : 1
Expand Down

0 comments on commit 03b645e

Please sign in to comment.