fix(theme): incorrect resolve sidebar

This commit is contained in:
pengzhanbo 2024-08-27 11:32:48 +08:00
parent b37de62121
commit d87e785e6f

View File

@ -4,6 +4,7 @@ import {
isArray,
isPlainObject,
isString,
removeLeadingSlash,
} from '@vuepress/helper/client'
import { useMediaQuery } from '@vueuse/core'
import type { ComputedRef, InjectionKey, Ref } from 'vue'
@ -99,7 +100,7 @@ export function getSidebar(routePath: string, routeLocal: string): ResolvedSideb
.sort((a, b) => b.split('/').length - a.split('/').length)
.find((dir) => {
// make sure the multi sidebar key starts with slash too
return routePath.startsWith(ensureLeadingSlash(dir))
return routePath.startsWith(`${routeLocal}${removeLeadingSlash(dir)}`)
}) || ''
const sidebar = dir ? _sidebar[dir] : undefined