INNER CODE UNIT · JavaScript
buildCategoryNode
tradingview/lightweight-charts · website/plugins/docs-markdown/index.js:199
function buildCategoryNode(item, docsById, baseUrl, contentRoot) {
if ((item.label ?? '').toLowerCase() === API_ROUTE_SEGMENT) {
return null;
}
const children = buildDocsNodes(item.items ?? [], docsById, baseUrl, contentRoot);
// Surface the category's own landing page as its first entry, so it is both
// mapped and written out.
const landingPage = item.link?.type === 'doc' && item.link.id !== undefined ? docsById.get(item.link.id) : undefined;
const landingNode = landingPage === undefined ? null : toDocNode(landingPage, baseUrl, contentRoot);
if (landingNode !== null) {
children.unshift(landingNode);
}
return children.length === 0 ? null : { kind: 'category', label: item.label ?? '', children };
}
/**
* @param {SidebarItem} item
* @param {Map<string, DocMetadata>} docsById