MCPcopy Create free account
hub / github.com/tinyplex/tinybase / getNav

Function getNav

site/ui/NavJson.tsx:35–64  ·  view source on GitHub ↗
(node: Node, pageNode: Node, isSingle: boolean)

Source from the content-addressed store, hash-verified

33};
34
35const getNav = (node: Node, pageNode: Node, isSingle: boolean): NavNode => {
36 const navNode: NavNode = {
37 i: node.id,
38 n: node.name,
39 u: (isSingle ? '#' : '') + node.url,
40 };
41
42 const children = getSkippedChildren(node);
43 const isParent = children.length > 0;
44 const isOpen = isSingle || isAncestorOrSame(pageNode, node);
45
46 if (node.reflection != null) {
47 navNode.r = 1;
48 }
49 if (!isSingle && node == pageNode) {
50 navNode.c = 1;
51 }
52 if (isParent) {
53 navNode.p = 1;
54 if (isOpen) {
55 navNode.o = 1;
56 }
57 }
58
59 if (isOpen && isParent) {
60 navNode._ = children.map((node) => getNav(node, pageNode, isSingle));
61 }
62
63 return navNode;
64};

Callers 1

NavJsonFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…