Open DiegoxK opened 5 months ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Updated (UTC) |
---|---|---|---|
react-notion-x | ✅ Ready (Inspect) | Visit Preview | Feb 6, 2024 11:48pm |
react-notion-x-minimal-demo | ✅ Ready (Inspect) | Visit Preview | Feb 6, 2024 11:48pm |
Description
I usually organize my Notion documents into two columns: one for the content itself and another for the table of contents.
To my surprise, the headers from the left column were not appearing in the table of contents:![Screenshot 2024-02-06 173013](https://github.com/NotionX/react-notion-x/assets/86527054/cc9267b9-e028-4e60-bbf6-dd920f22d440)
Upon inspecting the code, I realized that the
getPageTableOfContents
function only checks for the nearest children blocks of the root page and doesn't inspect sub-blocks for headers.My changes adds the
traverseBlocks
function to theget-page-table-of-contents
file, which recursively checks every block for headers:Following these changes, the table of contents displays all the headers in the same way Notion does when using the two column blocks.
Notion Test Page ID
159efb60502b435496e6e37ef8e2ed6f
I'm uncertain of any potential performance impacts by checking every block this way rather than directly filtering the
recordMap
. Any feedback is appreciated! ❤️