MCPcopy Create free account
hub / github.com/IABTechLab/uid2docs / TOCItems

Function TOCItems

src/theme/TOCItems/index.tsx:11–54  ·  view source on GitHub ↗
({
  toc,
  className = "table-of-contents table-of-contents__left-border",
  linkClassName = "table-of-contents__link",
  linkActiveClassName = undefined,
  minHeadingLevel: minHeadingLevelOption,
  maxHeadingLevel: maxHeadingLevelOption,
  ...props
}: Props)

Source from the content-addressed store, hash-verified

9import type { Props } from "@theme/TOCItems";
10
11export default function TOCItems({
12 toc,
13 className = "table-of-contents table-of-contents__left-border",
14 linkClassName = "table-of-contents__link",
15 linkActiveClassName = undefined,
16 minHeadingLevel: minHeadingLevelOption,
17 maxHeadingLevel: maxHeadingLevelOption,
18 ...props
19}: Props): JSX.Element | null {
20 const themeConfig = useThemeConfig();
21
22 const minHeadingLevel =
23 minHeadingLevelOption ?? themeConfig.tableOfContents.minHeadingLevel;
24 const maxHeadingLevel =
25 maxHeadingLevelOption ?? themeConfig.tableOfContents.maxHeadingLevel;
26
27 const tocTree = useFilteredAndTreeifiedTOC({
28 toc,
29 minHeadingLevel,
30 maxHeadingLevel,
31 });
32
33 const tocHighlightConfig: TOCHighlightConfig | undefined = useMemo(() => {
34 if (linkClassName && linkActiveClassName) {
35 return {
36 linkClassName,
37 linkActiveClassName,
38 minHeadingLevel,
39 maxHeadingLevel,
40 };
41 }
42 return undefined;
43 }, [linkClassName, linkActiveClassName, minHeadingLevel, maxHeadingLevel]);
44 useTOCHighlight(tocHighlightConfig);
45
46 return (
47 <TOCItemTree
48 toc={tocTree}
49 className={className}
50 linkClassName={linkClassName}
51 {...props}
52 />
53 );
54}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected