Skip to content

Commit dfb19e6

Browse files
committed
Add support for "none" group
1 parent ce7b3b4 commit dfb19e6

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/lib/output/themes/default/DefaultTheme.tsx

+16-12
Original file line numberDiff line numberDiff line change
@@ -383,21 +383,11 @@ export class DefaultTheme extends Theme {
383383
}
384384

385385
if (parent.categories && shouldShowCategories(parent, opts)) {
386-
const noneCategory = parent.categories.find((x) => x.title === "none");
387-
const otherCategories = parent.categories.filter((x) => x.title !== "none");
388-
389-
const mappedOthers = filterMap(otherCategories, toNavigation);
390-
391-
if (noneCategory) {
392-
const noneMappedChildren = filterMap(noneCategory.children, toNavigation);
393-
return [...noneMappedChildren, ...mappedOthers];
394-
}
395-
396-
return mappedOthers;
386+
return filterMapWithNoneCollection(parent.categories);
397387
}
398388

399389
if (parent.groups && shouldShowGroups(parent, opts)) {
400-
return filterMap(parent.groups, toNavigation);
390+
return filterMapWithNoneCollection(parent.groups);
401391
}
402392

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

400+
function filterMapWithNoneCollection(reflection: ReflectionGroup[] | ReflectionCategory[]) {
401+
const none = reflection.find((x) => x.title.toLocaleLowerCase() === "none");
402+
const others = reflection.filter((x) => x.title.toLocaleLowerCase() !== "none");
403+
404+
const mappedOthers = filterMap(others, toNavigation);
405+
406+
if (none) {
407+
const noneMappedChildren = filterMap(none.children, toNavigation);
408+
return [...noneMappedChildren, ...mappedOthers];
409+
}
410+
411+
return mappedOthers;
412+
}
413+
410414
function deriveModuleFolders(children: Array<DeclarationReflection | DocumentReflection>) {
411415
const result: NavigationElement[] = [];
412416

0 commit comments

Comments
 (0)