fix(theme): fix sidebar items prefix not handled correctly, close #876 (#885)

This commit is contained in:
pengzhanbo 2026-04-03 02:13:18 +08:00 committed by GitHub
parent 709ade741c
commit e9fe35bc4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -235,7 +235,12 @@ function getAllSidebar(): Record<string, ThemeSidebar> {
const sidebar = locale === '/' ? (opt.sidebar || options.sidebar) : opt.sidebar
locales[locale] = {}
for (const [key, value] of entries(sidebar || {})) {
locales[locale][ensureLeadingSlash(key)] = value
locales[locale][ensureLeadingSlash(key)] = isPlainObject(value) && 'items' in value
? { ...value, prefix: value.prefix?.startsWith('/') ? value.prefix : normalizeLink(locale, removeLeadingSlash(key)) }
: {
items: value,
prefix: normalizeLink(locale, removeLeadingSlash(key)),
}
}
const collections = rawCollections?.filter(item => item.type === 'doc')
if (collections?.length) {