diff --git a/theme/src/client/composables/sidebar.ts b/theme/src/client/composables/sidebar.ts index f36323a37..92927d594 100644 --- a/theme/src/client/composables/sidebar.ts +++ b/theme/src/client/composables/sidebar.ts @@ -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) diff --git a/theme/src/node/prepare/prepareSidebar.ts b/theme/src/node/prepare/prepareSidebar.ts index 69974f7fb..4d2b7c625 100644 --- a/theme/src/node/prepare/prepareSidebar.ts +++ b/theme/src/node/prepare/prepareSidebar.ts @@ -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