NotionX / NotionX/react-notion-x
getPageBreadcrumbs() result does not include collection parent page
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 645
- PR merge metrics
- No merged PRs in 30d
Description
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
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with getPageBreadcrumbs(recordMap, childPageId) and the linked packages/notion-utils/src/get-block-parent-page.ts. Trace how collection parents and collection_view_page records are handled, using the supplied Notion page ID as the reproduction case. Done means the breadcrumbs include Notion Dev Site / Test Db / Main Page for that child page.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100