From fa982e699b492abf506d54c4d4294b47366c0925 Mon Sep 17 00:00:00 2001 From: Zeno Kapitein Date: Mon, 3 Nov 2025 18:19:06 +0100 Subject: [PATCH] Treat pages without visible TOC items as `no-toc` --- .changeset/slow-boxes-go.md | 5 +++++ packages/gitbook/src/components/PageBody/PageBody.tsx | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changeset/slow-boxes-go.md 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 (