react-notion-x
react-notion-x copied to clipboard
getPageBreadcrumbs() result does not include collection parent page
trafficstars
Description
If the child page belongs to a "collection" (database) parent page, the result of getPageBreadcrumbs(recordMap, childPageId) does not include that parent database page.
Notion Test Page ID
f9ee16bddeac4ce58c3d3ce8055f78a9. This "Main Page" belongs to a "Test Db" collection page.
- The breadcrumbs of notion.site page: Notion Dev Site / Test Db / Main Page
- The breadcrumbs of getPageBreadcrumbs() : Notion Dev Site / Main Page
Possible Fix
To fix this problem, getBlockParentPage could be changed
export const getBlockParentPage = (
block: types.Block,
recordMap: types.ExtendedRecordMap,
{
inclusive = false
}: {
inclusive?: boolean
} = {}
): types.PageBlock | null => {
// ... omitted
if (parentTable === 'collection') {
currentRecord = recordMap.collection[parentId]?.value
} else {
currentRecord = recordMap.block[parentId]?.value
// -----> changed from: if ((currentRecord as types.Block)?.type === 'page') {
if ((currentRecord as types.Block)?.type === 'page' || (currentRecord as types.Block)?.type === 'collection_view_page') {
return currentRecord as types.PageBlock
}
}
}
return null
}