Skip to content

Commit 9022d87

Browse files
authored
Add page breadcrumbs to search results (#3784)
1 parent a49781e commit 9022d87

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

.changeset/busy-weeks-add.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+
Add breadcrumbs to search results

bun.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@
343343
"react-dom": "catalog:",
344344
},
345345
"catalog": {
346-
"@gitbook/api": "0.146.0",
346+
"@gitbook/api": "0.147.0",
347347
"@scalar/api-client-react": "^1.3.46",
348348
"@tsconfig/node20": "^20.1.6",
349349
"@tsconfig/strictest": "^2.0.6",
@@ -724,7 +724,7 @@
724724

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

727-
"@gitbook/api": ["@gitbook/api@0.146.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-gWcSCbN+9Zc/XOEk4t8v70kKyaVJQytHMnnstArr8av1YpHzZWEpVQCeQ20SnJvkvO5y+P7TCVxJCLG2ciT9SQ=="],
727+
"@gitbook/api": ["@gitbook/api@0.147.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-ON32kqr9ID6td9h26bmmPflpoKZZ3+Z0W5URjc/YIDfk+YFb7/rVrOGzYf3NV9R+uZuxVzIKRJ9Yq8v0WLVwNQ=="],
728728

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"catalog": {
4343
"@tsconfig/strictest": "^2.0.6",
4444
"@tsconfig/node20": "^20.1.6",
45-
"@gitbook/api": "0.146.0",
45+
"@gitbook/api": "0.147.0",
4646
"@scalar/api-client-react": "^1.3.46",
4747
"@types/react": "^19.0.0",
4848
"@types/react-dom": "^19.0.0",

packages/gitbook/src/components/Search/SearchPageResultItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ export const SearchPageResultItem = React.forwardRef(function SearchPageResultIt
5454
'transition-colors',
5555
'font-normal',
5656
'uppercase',
57-
'leading-none',
57+
'leading-snug',
5858
'tracking-wider',
5959
'mb-1',
6060
'flex',
6161
'flex-wrap',
6262
'gap-x-2',
63-
'gap-y-1',
63+
'gap-y-0',
6464
'items-center'
6565
)}
6666
>

packages/gitbook/src/components/Search/server-actions.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,21 @@ async function transformSitePageResult(
413413
icon: siteSection?.icon as IconName,
414414
label: siteSection.title,
415415
},
416-
(!siteSection || siteSection?.siteSpaces.length > 1) && siteSpace
416+
(siteSection?.siteSpaces?.filter(
417+
// If a space is the only one in its langauge, it's a translation variant and we don't want to show it.
418+
(space) =>
419+
siteSection?.siteSpaces?.filter(
420+
// Check if there are other spaces in the same language within the section.
421+
(s) => s.space.language === space.space.language
422+
).length > 1 // We only want to show the space if there are other spaces in the same language within the section.
423+
).length ?? 0) > 1 && siteSpace
417424
? {
418425
label: siteSpace.title,
419426
}
420427
: undefined,
428+
...pageItem.ancestors.map((ancestor) => ({
429+
label: ancestor.title,
430+
})),
421431
].filter((item) => item !== undefined),
422432
};
423433

0 commit comments

Comments
 (0)