diff --git a/.changeset/slow-boxes-go.md b/.changeset/slow-boxes-go.md new file mode 100644 index 0000000000..1d16b3fbe8 --- /dev/null +++ b/.changeset/slow-boxes-go.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Treat pages without visible TOC items as `no-toc` diff --git a/packages/gitbook/src/components/PageBody/PageBody.tsx b/packages/gitbook/src/components/PageBody/PageBody.tsx index adbe4de322..05fdb798a2 100644 --- a/packages/gitbook/src/components/PageBody/PageBody.tsx +++ b/packages/gitbook/src/components/PageBody/PageBody.tsx @@ -46,6 +46,11 @@ export function PageBody(props: { const language = getSpaceLanguage(context); const updatedAt = page.updatedAt ?? page.createdAt; + const hasVisibleTOCItems = + context.revision.pages.filter( + (page) => page.type !== 'document' || (page.type === 'document' && !page.hidden) + ).length > 0; + return (