MCPcopy Create free account
hub / github.com/code100x/daily-code / collectContentBlockIds

Function collectContentBlockIds

apps/web/lib/notion.ts:18–39  ·  view source on GitHub ↗
(recordMap: any)

Source from the content-addressed store, hash-verified

16 return normalizedBlock;
17}
18
19function collectContentBlockIds(recordMap: any): string[] {
20 const blocks = recordMap?.block;
21 if (!blocks) return [];
22 const rootId = Object.keys(blocks)[0];
23 if (!rootId) return [];
24
25 const seen = new Set<string>();
26 const walk = (id: string) => {
27 if (seen.has(id)) return;
28 seen.add(id);
29 const value = blocks[id]?.value;
30 if (!value) return;
31 if (id !== rootId && (value.type === "page" || value.type === "collection_view_page")) return;
32 if (Array.isArray(value.content)) {
33 for (const childId of value.content) walk(childId);
34 }
35 const refId = value.format?.transclusion_reference_pointer?.id;
36 if (refId) walk(refId);
37 };
38 walk(rootId);
39 return Array.from(seen);
40}
41
42// --- Why this file looks the way it does -------------------------------------

Callers 1

fetchNotionPageFunction · 0.85

Calls 1

walkFunction · 0.85

Tested by

no test coverage detected