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

Function TOCItemTree

src/theme/TOCItems/Tree.tsx:5–35  ·  view source on GitHub ↗
({
  toc,
  className,
  linkClassName,
  isChild,
}: Props)

Source from the content-addressed store, hash-verified

3
4// Recursive component rendering the toc tree
5function TOCItemTree({
6 toc,
7 className,
8 linkClassName,
9 isChild,
10}: Props): JSX.Element | null {
11 if (!toc.length) {
12 return null;
13 }
14 return (
15 <ul className={isChild ? undefined : className}>
16 {toc.map((heading) => (
17 <li key={heading.id}>
18 <a
19 href={`#${heading.id}`}
20 className={linkClassName ?? undefined}
21 dangerouslySetInnerHTML={{
22 __html: `<span class="type-theta border-underline-link">${heading.value}</span>`,
23 }}
24 />
25 <TOCItemTree
26 isChild
27 toc={heading.children}
28 className={className}
29 linkClassName={linkClassName}
30 />
31 </li>
32 ))}
33 </ul>
34 );
35}
36
37// Memo only the tree root is enough
38export default React.memo(TOCItemTree);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected