From 158263e557d92a70ebbbb1cf8aa5d88b3a6b85d7 Mon Sep 17 00:00:00 2001 From: Zeno Kapitein Date: Fri, 19 Sep 2025 15:02:08 +0200 Subject: [PATCH] Filter unindexable spaces --- .../gitbook/src/components/Header/Header.tsx | 15 ++- .../components/SpaceLayout/SpaceLayout.tsx | 9 +- packages/gitbook/src/lib/seo.ts | 92 ++++++++++++++++++- 3 files changed, 111 insertions(+), 5 deletions(-) diff --git a/packages/gitbook/src/components/Header/Header.tsx b/packages/gitbook/src/components/Header/Header.tsx index b952f5d59..681a262e1 100644 --- a/packages/gitbook/src/components/Header/Header.tsx +++ b/packages/gitbook/src/components/Header/Header.tsx @@ -2,7 +2,9 @@ import type { GitBookSiteContext } from '@/lib/context'; import { CONTAINER_STYLE, HEADER_HEIGHT_DESKTOP } from '@/components/layout'; import { getSpaceLanguage, t } from '@/intl/server'; +import { filterSectionsWithIndexableSpaces } from '@/lib/seo'; import { tcls } from '@/lib/tailwind'; +import { flattenSectionsFromGroup } from '@/lib/utils'; import { SearchContainer } from '../Search'; import { SiteSectionTabs, encodeClientSiteSections } from '../SiteSections'; import { HeaderLink } from './HeaderLink'; @@ -15,7 +17,7 @@ import { TranslationsDropdown } from './SpacesDropdown'; /** * Render the header for the space. */ -export function Header(props: { +export async function Header(props: { context: GitBookSiteContext; withTopHeader?: boolean; withVariants?: 'generic' | 'translations'; @@ -23,6 +25,14 @@ export function Header(props: { const { context, withTopHeader, withVariants } = props; const { siteSpace, siteSpaces, sections, customization } = context; + // Filter sections to only include those with indexable spaces + const filteredSections = sections?.list + ? await filterSectionsWithIndexableSpaces( + context, + flattenSectionsFromGroup(sections.list).filter((s) => s.object === 'site-section') + ) + : []; + return (