import * as types from 'notion-types' ; import { getBlockTitle } from './get-block-title' ; import { getBlockIcon } from './get-block-icon' ; import { getBlockParentPage } from './get-block-parent-page' ; export const getPageBreadcrumbs = ( recordMap , activePageId ) : Array < any > | null => { const blockMap = recordMap . block ; const breadcrumbs = [ ] ; let currentPageId = activePageId ; do { const block = blockMap [ currentPageId ] ?. value ; if ( ! block ) { break ; } const title = getBlockTitle ( block , recordMap ) ; const icon = getBlockIcon ( block , recordMap ) ; if ( ! ( title || icon ) ) { break ; } breadcrumbs . push ( { block , active : currentPageId === activePageId , pageId : currentPageId , title , icon } ) ; const parentBlock = getBlockParentPage ( block , recordMap ) ; const parentId = parentBlock ?. id ; if ( ! parentId ) { break ; } currentPageId = parentId ; } while ( true ) ; breadcrumbs . reverse ( ) ; return breadcrumbs ; } ;