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

fix #48 #49

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/plugin/src/plugin/sidebar.ts
Expand Up @@ -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) {
Expand Down