From ab5184fa086d6158dc227e1b4b7c79212147db4b Mon Sep 17 00:00:00 2001 From: puneet Date: Fri, 1 Mar 2024 14:18:35 +0530 Subject: [PATCH] API Structures Sidebar Not Alphabetized --- scripts/tasks/create-sidebar.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/tasks/create-sidebar.ts b/scripts/tasks/create-sidebar.ts index a138ff044..c07c62f1b 100644 --- a/scripts/tasks/create-sidebar.ts +++ b/scripts/tasks/create-sidebar.ts @@ -178,6 +178,22 @@ export const createSidebar = async (root: string, destination: string) => { prettierConfig ); + for (const id of Object.keys(sidebars)) { + for (const category of sidebars[id]) { + setRecursive(category); + // Sort items alphabetically within each category + category.items.sort((a, b) => { + if (typeof a === 'string' && typeof b === 'string') { + return a.localeCompare(b); + } else if (a.label && b.label) { + return a.label.localeCompare(b.label); + } else { + return 0; + } + }); + } + } + await fs.writeFile(destination, formattedSidebarString, 'utf-8'); } else { logger.info(`No new documents found`);