Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Structures Sidebar Not Alphabetized #526

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue(blocking): this won't work because the formattedSidebarString is parsed before we do any of the in-place sorting.

I also think we would want to only have this available for the API Structures categories, rather than every single sidebar category recursively.

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