Skip to content

Commit 04a4175

Browse files
authored
Remove hidden site spaces from navigation (#3795)
1 parent 3e40b4d commit 04a4175

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

.changeset/three-melons-enjoy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'gitbook': patch
3+
---
4+
5+
Remove hidden site spaces from navigation

bun.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@
344344
"react-dom": "catalog:",
345345
},
346346
"catalog": {
347-
"@gitbook/api": "0.150.0",
347+
"@gitbook/api": "0.151.0",
348348
"@scalar/api-client-react": "^1.3.46",
349349
"@tsconfig/node20": "^20.1.6",
350350
"@tsconfig/strictest": "^2.0.6",
@@ -725,7 +725,7 @@
725725

726726
"@fortawesome/fontawesome-svg-core": ["@fortawesome/fontawesome-svg-core@6.6.0", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "6.6.0" } }, "sha512-KHwPkCk6oRT4HADE7smhfsKudt9N/9lm6EJ5BVg0tD1yPA5hht837fB87F8pn15D8JfTqQOjhKTktwmLMiD7Kg=="],
727727

728-
"@gitbook/api": ["@gitbook/api@0.150.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-OjP52+BlBCo3BvKhLz5exR8uvzT9XaYuMACC72LGSsvyz7Ejiehs2JMrCmX3zQF1aJ+UemT6TTZCUx1T0PQyuQ=="],
728+
"@gitbook/api": ["@gitbook/api@0.151.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-5d9+rZ2u6CKKIiVHO1Toyk+7wHtTOXmP0+sVIE3teRkceX4z5FGIIpa4XsFeKC9XeosncvehdshPaOGQtSDpTQ=="],
729729

730730
"@gitbook/browser-types": ["@gitbook/browser-types@workspace:packages/browser-types"],
731731

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"catalog": {
4242
"@tsconfig/strictest": "^2.0.6",
4343
"@tsconfig/node20": "^20.1.6",
44-
"@gitbook/api": "0.150.0",
44+
"@gitbook/api": "0.151.0",
4545
"@scalar/api-client-react": "^1.3.46",
4646
"@types/react": "^19.0.0",
4747
"@types/react-dom": "^19.0.0",

packages/gitbook/src/lib/context.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export async function fetchSiteContextByIds(
274274
);
275275
}
276276

277-
return { siteSpaces, siteSpace };
277+
return { siteSpaces: filterHiddenSiteSpaces(siteSpaces), siteSpace };
278278
}
279279

280280
if (siteStructure.type === 'sections') {
@@ -295,7 +295,7 @@ export async function fetchSiteContextByIds(
295295
);
296296
}
297297

298-
return { siteSpaces, siteSpace };
298+
return { siteSpaces: filterHiddenSiteSpaces(siteSpaces), siteSpace };
299299
}
300300

301301
// @ts-expect-error
@@ -426,6 +426,13 @@ export function checkIsRootSiteContext(context: GitBookSiteContext): boolean {
426426
}
427427
}
428428

429+
/**
430+
* Filter out hidden site spaces from a list of site spaces.
431+
*/
432+
function filterHiddenSiteSpaces(siteSpaces: SiteSpace[]): SiteSpace[] {
433+
return siteSpaces.filter((siteSpace) => !siteSpace.hidden);
434+
}
435+
429436
function parseSiteSectionsAndGroups(structure: SiteStructure, siteSectionId: string) {
430437
const sectionsAndGroups = getSiteStructureSections(structure, { ignoreGroups: false });
431438
const section = parseCurrentSection(structure, siteSectionId);

0 commit comments

Comments
 (0)