Skip to content

Commit

Permalink
Add support for "none" group
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-ls committed Aug 12, 2024
1 parent ce7b3b4 commit dfb19e6
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/lib/output/themes/default/DefaultTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -383,21 +383,11 @@ export class DefaultTheme extends Theme {
}

if (parent.categories && shouldShowCategories(parent, opts)) {
const noneCategory = parent.categories.find((x) => x.title === "none");
const otherCategories = parent.categories.filter((x) => x.title !== "none");

const mappedOthers = filterMap(otherCategories, toNavigation);

if (noneCategory) {
const noneMappedChildren = filterMap(noneCategory.children, toNavigation);
return [...noneMappedChildren, ...mappedOthers];
}

return mappedOthers;
return filterMapWithNoneCollection(parent.categories);
}

if (parent.groups && shouldShowGroups(parent, opts)) {
return filterMap(parent.groups, toNavigation);
return filterMapWithNoneCollection(parent.groups);
}

if (opts.includeFolders && parent.childrenIncludingDocuments?.some((child) => child.name.includes("/"))) {
Expand All @@ -407,6 +397,20 @@ export class DefaultTheme extends Theme {
return filterMap(parent.childrenIncludingDocuments, toNavigation);
}

function filterMapWithNoneCollection(reflection: ReflectionGroup[] | ReflectionCategory[]) {
const none = reflection.find((x) => x.title.toLocaleLowerCase() === "none");
const others = reflection.filter((x) => x.title.toLocaleLowerCase() !== "none");

const mappedOthers = filterMap(others, toNavigation);

if (none) {
const noneMappedChildren = filterMap(none.children, toNavigation);
return [...noneMappedChildren, ...mappedOthers];
}

return mappedOthers;
}

function deriveModuleFolders(children: Array<DeclarationReflection | DocumentReflection>) {
const result: NavigationElement[] = [];

Expand Down

0 comments on commit dfb19e6

Please sign in to comment.