Skip to content

Commit

Permalink
fix(content-docs): auto-generate sidebar with alphabetically ordered …
Browse files Browse the repository at this point in the history
…labels by default
  • Loading branch information
Josh-Cena committed Mar 3, 2022
1 parent 1c91d2f commit 9c7aab9
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,13 @@ export const DefaultSidebarItemsGenerator: SidebarItemsGenerator = async ({
});
const sortedSidebarItems = _.sortBy(
processedSidebarItems,
(item) => item.position,
(item) =>
item.position ??
// Our generator only generates items with "category" and "doc" types,
// but if we allow "items" as category metadata others may be possible
(['category', 'doc', 'ref', 'link'].includes(item.type)
? (item as {label: string}).label
: undefined),
);
return sortedSidebarItems.map(({position, ...item}) => item);
}
Expand Down

0 comments on commit 9c7aab9

Please sign in to comment.