MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / nextRouteTable

Function nextRouteTable

src/resolution/frameworks/nextjs.ts:134–151  ·  view source on GitHub ↗
(context: ResolutionContext)

Source from the content-addressed store, hash-verified

132}
133
134export function nextRouteTable(context: ResolutionContext): NextTable {
135 const all = context.getNodesByKind('route');
136 const cached = tables.get(context);
137 if (cached && cached.source === all) return cached;
138 const exact = new Map<string, Node>();
139 const dynamic: RouteTable['dynamic'] = [];
140 const roots = new Set<string>();
141 for (const node of all) {
142 const file = tablePage(node);
143 if (!file) continue;
144 exact.set(node.name, node);
145 if (node.name.includes(':')) dynamic.push({ node, segs: node.name.split('/').slice(1) });
146 roots.add(file.root);
147 }
148 const table: NextTable = { source: all, exact, dynamic, roots: [...roots] };
149 tables.set(context, table);
150 return table;
151}
152
153/** `/users/${…}?tab=x` → `['users', '*']`; an absolute URL keeps its path; a relative href is nothing. */
154function hrefSegments(href: HrefLiteral): string[] | null {

Callers 3

nextLinkEdgesFunction · 0.90
nextjs.tsFile · 0.85
resolveFunction · 0.85

Calls 6

tablePageFunction · 0.85
pushMethod · 0.80
getNodesByKindMethod · 0.65
getMethod · 0.65
setMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected