From e9fe35bc4f172ff6a004e0170b476173cce2e4c1 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Fri, 3 Apr 2026 02:13:18 +0800 Subject: [PATCH] fix(theme): fix sidebar items prefix not handled correctly, close #876 (#885) --- theme/src/node/prepare/prepareSidebar.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/theme/src/node/prepare/prepareSidebar.ts b/theme/src/node/prepare/prepareSidebar.ts index 663e4f32..18ac36cb 100644 --- a/theme/src/node/prepare/prepareSidebar.ts +++ b/theme/src/node/prepare/prepareSidebar.ts @@ -235,7 +235,12 @@ function getAllSidebar(): Record { 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) {