MCPcopy Create free account
hub / github.com/fontsource/fontsource / RootSection

Function RootSection

website/app/components/docs/LeftSidebar.tsx:164–206  ·  view source on GitHub ↗
({
	node,
	currentPath,
	toggle,
}: {
	node: PageTree.Node;
	currentPath: string;
	toggle?: () => void;
})

Source from the content-addressed store, hash-verified

162);
163
164const RootSection = ({
165 node,
166 currentPath,
167 toggle,
168}: {
169 node: PageTree.Node;
170 currentPath: string;
171 toggle?: () => void;
172}) => {
173 switch (node.type) {
174 case 'page':
175 return (
176 <PageLink
177 node={node}
178 className={classes.rootSection}
179 active={currentPath === node.url}
180 iconClassName={classes.rootSectionIcon}
181 toggle={toggle}
182 />
183 );
184 case 'folder': {
185 const url = firstInternalPageUrl(node);
186 if (!url) return null;
187
188 const active = containsCurrentPage(node, currentPath);
189
190 return (
191 <Link
192 className={classes.rootSection}
193 to={url}
194 prefetch="render"
195 data-active={active}
196 aria-current={active ? 'location' : undefined}
197 onClick={toggle}
198 >
199 <span>{node.name}</span>
200 </Link>
201 );
202 }
203 default:
204 return null;
205 }
206};
207
208const LeftSidebar = ({ tree, toggle }: LeftSidebarProps) => {
209 const pageTree = usePageTree(tree);

Callers

nothing calls this directly

Calls 2

containsCurrentPageFunction · 0.85
firstInternalPageUrlFunction · 0.70

Tested by

no test coverage detected