@@ -7,23 +7,23 @@ import {navigate} from "svelte-navigator";
77import { getNotionAuth } from "./session.js" ;
88
99
10- const DEFAULT_SETTINGS = { showTitle : true , showIcon : true , backgroundShadow : true , showFirst : true } ;
10+ const DEFAULT_SETTINGS = { showTitle : true , showIcon : true , backgroundShadow : true , showFirst : true , TOCLevel : 3 } ;
1111
1212
1313function fakeText ( ) {
1414 return data
1515}
1616
17- function findAllTitles ( items , registry ) {
17+ function findAllTitles ( items , registry , settings ) {
1818
1919 for ( const item of items ) {
20- if ( [ "heading_1" , "heading_2" , "heading_3" ] . includes ( item . type ) ) {
21- const title = { type :item . type , content :item . block [ item . type ] , children :[ ] }
20+ if ( [ "heading_1" , "heading_2" , "heading_3" ] . slice ( 0 , settings . TOCLevel ) . includes ( item . type ) ) {
21+ const title = { type : item . type , content : item . block [ item . type ] , children : [ ] }
2222 registry . push ( title )
2323
2424 continue ;
2525 }
26- findAllTitles ( item . children , registry )
26+ findAllTitles ( item . children , registry , settings )
2727 }
2828}
2929
@@ -80,6 +80,11 @@ function slideInitializer() {
8080 case "hideFirst" :
8181 newSettings . showFirst = false ;
8282 break ;
83+ case "2levelTOC" :
84+ newSettings . TOCLevel = 2 ;
85+ break ;
86+ case "1levelTOC" :
87+ newSettings . TOCLevel = 1 ;
8388 }
8489 }
8590 return { ...DEFAULT_SETTINGS , ...newSettings } ;
@@ -101,7 +106,7 @@ function slideInitializer() {
101106 let data = [ ] ;
102107 let page = loaded . page
103108 let settings = processSettings ( page )
104- findAllTitles ( loaded . blocks , toc )
109+ findAllTitles ( loaded . blocks , toc , settings )
105110
106111 let currentPage = 0 ;
107112 for ( let block of loaded . blocks ) {
0 commit comments