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

Function flattenPages

website/app/utils/docs/navigation.ts:40–69  ·  view source on GitHub ↗
(tree: PageTree.Root)

Source from the content-addressed store, hash-verified

38};
39
40export const flattenPages = (tree: PageTree.Root): PageLink[] => {
41 const pages: PageLink[] = [];
42
43 const visit = (nodes: PageTree.Node[]) => {
44 for (const node of nodes) {
45 if (isPage(node)) {
46 pages.push({
47 name: nodeName(node),
48 url: node.url,
49 external: node.external,
50 });
51 continue;
52 }
53
54 if (isFolder(node)) {
55 if (node.index) {
56 pages.push({
57 name: nodeName(node.index),
58 url: node.index.url,
59 external: node.index.external,
60 });
61 }
62 visit(node.children);
63 }
64 }
65 };
66
67 visit(tree.children);
68 return pages;
69};
70
71export const getPager = (tree: PageTree.Root, url: string): Pager => {
72 const pages = flattenPages(tree).filter((page) => !page.external);

Callers 1

getPagerFunction · 0.85

Calls 1

visitFunction · 0.85

Tested by

no test coverage detected