Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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! ❤️