diff --git a/src/lib/output/themes/default/DefaultTheme.tsx b/src/lib/output/themes/default/DefaultTheme.tsx index d675659cd..a3ab05b79 100644 --- a/src/lib/output/themes/default/DefaultTheme.tsx +++ b/src/lib/output/themes/default/DefaultTheme.tsx @@ -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("/"))) { @@ -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) { const result: NavigationElement[] = [];