File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
packages/gitbook/src/components/PageBody Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " gitbook " : patch
3+ ---
4+
5+ Treat pages without visible TOC items as ` no-toc `
Original file line number Diff line number Diff line change @@ -46,6 +46,11 @@ export function PageBody(props: {
4646 const language = getSpaceLanguage ( context ) ;
4747 const updatedAt = page . updatedAt ?? page . createdAt ;
4848
49+ const hasVisibleTOCItems =
50+ context . revision . pages . filter (
51+ ( page ) => page . type !== 'document' || ( page . type === 'document' && ! page . hidden )
52+ ) . length > 0 ;
53+
4954 return (
5055 < CurrentPageProvider page = { { spaceId : context . space . id , pageId : page . id } } >
5156 < main
@@ -56,7 +61,9 @@ export function PageBody(props: {
5661 'break-anywhere' ,
5762 pageWidthWide ? 'page-width-wide 3xl:px-8' : 'page-width-default' ,
5863 siteWidthWide ? 'site-width-wide' : 'site-width-default' ,
59- page . layout . tableOfContents ? 'page-has-toc' : 'page-no-toc'
64+ page . layout . tableOfContents && hasVisibleTOCItems
65+ ? 'page-has-toc'
66+ : 'page-no-toc'
6067 ) }
6168 >
6269 < PreservePageLayout siteWidthWide = { siteWidthWide } />
You can’t perform that action at this time.
0 commit comments