From f480162b4d64ddfb0e19fbf50751a3977ebb28e9 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 11 Oct 2023 11:56:40 +0800 Subject: [PATCH] chore: small fix in the plugin --- content/@theme/plugin.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/content/@theme/plugin.js b/content/@theme/plugin.js index 9f6b64f338..2c7f8c1f6b 100644 --- a/content/@theme/plugin.js +++ b/content/@theme/plugin.js @@ -15,6 +15,12 @@ export default function indexPagesPlugin() { // this uses some internals, we will expose them in nicer way in the future releases const sidebarId = actions.routesSharedData.get(route.slug)?.['sidebar']; // TODO: implement a helper function for this const sidebar = await readSharedData(sidebarId, actions.outdir); + + if (!sidebar) { + console.log('Index route used with no sidebar', route.fsPath); + continue; + } + const item = findItemDeep(sidebar.items, route.fsPath); const childrenPaths =(item.items || []).map(item => item.fsPath).filter(Boolean);