File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
packages/notion-utils/src Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,11 @@ export const getPageTableOfContents = (
4747 }
4848 }
4949
50- if ( type === 'transclusion_container' ) {
50+ if (
51+ type === 'transclusion_container' ||
52+ type === 'column_list' ||
53+ type === 'column'
54+ ) {
5155 return mapContentToEntries ( block . content )
5256 }
5357 }
@@ -56,10 +60,15 @@ export const getPageTableOfContents = (
5660 } )
5761 }
5862
59- const toc = mapContentToEntries ( page . content )
60- // Synced blocks cannot be nested. So theoretically a 1-level flattening is enough.
61- . flat ( )
62- . filter ( Boolean ) as Array < TableOfContentsEntry >
63+ // Helper function to flatten nested results recursively
64+ function flattenResults ( results : MapResult [ ] ) : TableOfContentsEntry [ ] {
65+ return results . flatMap ( ( r ) => {
66+ if ( r == null ) return [ ]
67+ return Array . isArray ( r ) ? flattenResults ( r ) : [ r ]
68+ } )
69+ }
70+
71+ const toc = flattenResults ( mapContentToEntries ( page . content ) )
6372
6473 const indentLevelStack = [
6574 {
You can’t perform that action at this time.
0 commit comments