Skip to content

Commit cb102a6

Browse files
committed
chore: allow typedoc theme even without default group options
1 parent 76cc6b5 commit cb102a6

File tree

1 file changed

+16
-3
lines changed
  • packages/core-theme-documentation-generator/src

1 file changed

+16
-3
lines changed

packages/core-theme-documentation-generator/src/theme.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
import {
22
DefaultTheme,
33
DefaultThemeRenderContext,
4-
JSX, // eslint-disable-line @typescript-eslint/no-unused-vars
4+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
5+
JSX,
56
PageEvent,
67
Reflection,
78
ReflectionCategory,
9+
ReflectionKind,
810
} from "typedoc";
911

1012
class SdkThemeContext extends DefaultThemeRenderContext {
1113
override primaryNavigation = (props: PageEvent<Reflection>) => {
12-
const defaultGroup = this.options.getValue("defaultGroup") as string;
13-
const { categories } = props.model?.["groups"]?.find((value) => value.title === defaultGroup) ?? {};
14+
const categories = [];
15+
try {
16+
const defaultGroup = this.options.getValue("defaultGroup") as string;
17+
const group = props.model?.["groups"]?.find((value) => value.title === defaultGroup) ?? {};
18+
categories.push(...(group.categories || []));
19+
} catch (err) {
20+
console.warn("No value was set for `defaultGroup` options");
21+
if (props.model.isProject()) {
22+
const category = new ReflectionCategory("Modules");
23+
category.children.push(...props.model.getChildrenByKind(ReflectionKind.SomeModule));
24+
categories.push(category);
25+
}
26+
}
1427
if (categories?.length) {
1528
const selected = props.model.isProject();
1629

0 commit comments

Comments
 (0)