import { getBlockChildren } from './getBlockChildren'; import { isSupportedBlockType } from './utils'; const listTypes = new Set([ 'bulleted_list_item', 'numbered_list_item', 'to_do', ]); export async function getBlockTree(id: string) { const blocks = await addChildrenBlocks(id); return blocks; } // A function that recursively call getBlockChildren() until there is no more children // It returns the complete tree of notion blocks async function addChildrenBlocks(id: string) { let blocks = await getBlockChildren(id); blocks = await Promise.all( blocks.map(async (block, i, blocks) => { const { id, type } = block; if (!isSupportedBlockType(type)) { console.warn( `${type} blocks are not supported in this version of astro-notion and will not be rendered.` ); return ''; } // This part is for checking if each block is either the first or last item of the list element(