MCPcopy Index your code
hub / github.com/splitbee/react-notion / groupBlockContent

Function groupBlockContent

src/utils.ts:10–33  ·  view source on GitHub ↗
(blockMap: BlockMapType)

Source from the content-addressed store, hash-verified

8};
9
10const groupBlockContent = (blockMap: BlockMapType): string[][] => {
11 const output: string[][] = [];
12
13 let lastType: string | undefined = undefined;
14 let index = -1;
15
16 Object.keys(blockMap).forEach(id => {
17 blockMap[id].value.content?.forEach(blockId => {
18 const blockType = blockMap[blockId]?.value?.type;
19
20 if (blockType && blockType !== lastType) {
21 index++;
22 lastType = blockType;
23 output[index] = [];
24 }
25
26 output[index].push(blockId);
27 });
28
29 lastType = undefined;
30 });
31
32 return output;
33};
34
35export const getListNumber = (blockId: string, blockMap: BlockMapType) => {
36 const groups = groupBlockContent(blockMap);

Callers 1

getListNumberFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected