Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getPageBreadcrumbs() result does not include collection parent page #587

Open
sagan opened this issue Nov 19, 2024 · 0 comments
Open

getPageBreadcrumbs() result does not include collection parent page #587

sagan opened this issue Nov 19, 2024 · 0 comments

Comments

@sagan
Copy link

sagan commented Nov 19, 2024

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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant