From a78a2fc3e0cf8b564f371d9509d1fd657d851b49 Mon Sep 17 00:00:00 2001 From: suressk Date: Thu, 23 Jun 2022 17:09:03 +0800 Subject: [PATCH] fix: skip traverse the property when it doesn't exist --- src/client/theme-default/support/sidebar.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/client/theme-default/support/sidebar.ts b/src/client/theme-default/support/sidebar.ts index a22cef54..3559de32 100644 --- a/src/client/theme-default/support/sidebar.ts +++ b/src/client/theme-default/support/sidebar.ts @@ -33,6 +33,26 @@ export function getFlatSideBarLinks( const links: DefaultTheme.SidebarItem[] = [] for (const group of sidebar) { + // make sure sidebar entry didn't config the items property without build error + if (!group.items || !Array.isArray(group.items)) { + continue + } + /** + * the group.items need to be checked if items didn't be configed + * + * Alternatively, document `items` as required, even if it will be an empty array in the Config-Docs page + * + * in `.vitepress/config.[ts/js]` like this will throw error: + * { + * siderbar: [ + * '/mood/': [ + * { + * text: 'Mood Index' + * } + * ] + * ] + * } + */ for (const link of group.items) { links.push(link) }