ig-typedoc-theme
Version:
infragistics theme for typedoc API documentation with versioning and localization
36 lines (35 loc) • 2.09 kB
JavaScript
import { classNames, wbr } from '../utils/lib.js';
import { JSX, ReflectionKind, ContainerReflection } from 'typedoc';
export function navigation(context, props) {
return (JSX.createElement(JSX.Fragment, null,
primaryNavigation(context, props),
secondaryNavigation(context, props)));
}
function primaryNavigation(context, props) {
const modules = props.model.project.getChildrenByKind(ReflectionKind.SomeModule);
const projectLinkName = modules.some((m) => m.kindOf(ReflectionKind.Module)) ? "Modules" : "Exports";
return (JSX.createElement("nav", { class: "tsd-navigation primary" },
JSX.createElement("ul", null,
JSX.createElement("li", { class: classNames({ current: props.model.isProject() }) },
JSX.createElement("a", { href: context.urlTo(props.model.project) }, projectLinkName)))));
}
function secondaryNavigation(context, props) {
const children = props.model instanceof ContainerReflection ? props.model.children || [] : [];
if (props.model.isProject() && props.model.getChildrenByKind(ReflectionKind.Module).length) {
return;
}
const pageNavigation = (JSX.createElement("ul", null, children
.filter((child) => !child.kindOf(ReflectionKind.SomeModule))
.map((child) => {
return (JSX.createElement("li", { class: ReflectionKind.classString(child.kind) },
JSX.createElement("a", { href: context.urlTo(child), class: "tsd-kind-icon" }, wbr(child.name))));
})));
if (props.model.kindOf(ReflectionKind.SomeModule | ReflectionKind.Project)) {
return JSX.createElement("nav", { class: "tsd-navigation secondary menu-sticky" }, pageNavigation);
}
return (JSX.createElement("nav", { class: "tsd-navigation secondary menu-sticky" },
JSX.createElement("ul", null,
JSX.createElement("li", { class: "current " + ReflectionKind.classString(props.model.kind) },
JSX.createElement("a", { href: context.urlTo(props.model), class: "tsd-kind-icon" }, wbr(props.model.name)),
pageNavigation))));
}