From 146fe125727245c88b722cf58760333b6fdc1b15 Mon Sep 17 00:00:00 2001 From: Chad Hietala Date: Sun, 10 Jul 2022 14:49:02 -0400 Subject: [PATCH] fix #48 --- packages/plugin/src/plugin/sidebar.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/plugin/src/plugin/sidebar.ts b/packages/plugin/src/plugin/sidebar.ts index 41cc887..681fb96 100644 --- a/packages/plugin/src/plugin/sidebar.ts +++ b/packages/plugin/src/plugin/sidebar.ts @@ -9,15 +9,21 @@ export function groupSidebarItems( groups: JSONOutput.ReflectionGroup[], ): SidebarItem[] { const items: SidebarItem[] = []; - const sortedGroups = groups.sort((a, b) => a.title.localeCompare(b.title)); + + const categories = groups.flatMap(group => { + // Prefer @category annotation over built-in grouping + return group.categories || group + }); + + const sortedCategories = categories.sort((a, b) => a.title.localeCompare(b.title)); function getLastItemInGroup(index: number) { - const length = sortedGroups[index]?.children?.length; + const length = sortedCategories[index]?.children?.length; - return length ? sortedGroups[index]?.children?.[length - 1] : undefined; + return length ? sortedCategories[index]?.children?.[length - 1] : undefined; } - sortedGroups.forEach((group, groupIndex) => { + sortedCategories.forEach((group, groupIndex) => { const { children } = group; if (!children || children.length === 0) {