Skip to content

Commit

Permalink
API Structures Sidebar Not Alphabetized
Browse files Browse the repository at this point in the history
  • Loading branch information
botPuneet committed Mar 1, 2024
1 parent f00883e commit ab5184f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions scripts/tasks/create-sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down

0 comments on commit ab5184f

Please sign in to comment.