+
{t(language, 'search_no_results', query)}
);
- return (
-
- {children}
- {results.length === 0 ? (
- query ? (
- noResults
- ) : null
- ) : (
- <>
-
- {results.map((item, index) => {
- switch (item.type) {
- case 'page': {
- return (
- {
- refs.current[index] = ref;
- }}
- key={item.id}
- query={query}
- item={item}
- active={index === cursor}
- />
- );
- }
- case 'question': {
- return (
- {
- refs.current[index] = ref;
- }}
- key={item.id}
- question={query}
- active={index === cursor}
- onClick={onSwitchToAsk}
- />
- );
- }
- case 'recommended-question': {
- return (
- {
- refs.current[index] = ref;
- }}
- key={item.id}
- question={item.question}
- active={index === cursor}
- onClick={onSwitchToAsk}
- recommended
- />
- );
- }
- case 'section': {
- return (
- {
- refs.current[index] = ref;
- }}
- key={item.id}
- query={query}
- item={item}
- active={index === cursor}
- />
- );
- }
- default:
- assertNever(item);
- }
- })}
-
- {!results.some((result) => result.type !== 'question') && noResults}
- >
- )}
-
+ return results.length === 0 ? (
+ query ? (
+ noResults
+ ) : null
+ ) : (
+ <>
+
+ {results.map((item, index) => {
+ switch (item.type) {
+ case 'page': {
+ return (
+ {
+ refs.current[index] = ref;
+ }}
+ key={item.id}
+ query={query}
+ item={item}
+ active={index === cursor}
+ />
+ );
+ }
+ case 'question': {
+ return (
+ {
+ refs.current[index] = ref;
+ }}
+ key={item.id}
+ question={query}
+ active={index === cursor}
+ onClick={onSwitchToAsk}
+ />
+ );
+ }
+ case 'recommended-question': {
+ return (
+ {
+ refs.current[index] = ref;
+ }}
+ key={item.id}
+ question={item.question}
+ active={index === cursor}
+ onClick={onSwitchToAsk}
+ recommended
+ />
+ );
+ }
+ case 'section': {
+ return (
+ {
+ refs.current[index] = ref;
+ }}
+ key={item.id}
+ query={query}
+ item={item}
+ active={index === cursor}
+ />
+ );
+ }
+ default:
+ assertNever(item);
+ }
+ })}
+
+ {!results.some((result) => result.type !== 'question') && noResults}
+ >
);
});
diff --git a/packages/gitbook/src/components/Search/SearchSectionResultItem.tsx b/packages/gitbook/src/components/Search/SearchSectionResultItem.tsx
index ee2daa1ff..b754ff93b 100644
--- a/packages/gitbook/src/components/Search/SearchSectionResultItem.tsx
+++ b/packages/gitbook/src/components/Search/SearchSectionResultItem.tsx
@@ -3,7 +3,8 @@ import React from 'react';
import { tcls } from '@/lib/tailwind';
-import { Link } from '../primitives';
+import { tString, useLanguage } from '@/intl/client';
+import { Button, Link } from '../primitives';
import { HighlightQuery } from './HighlightQuery';
import type { ComputedSectionResult } from './server-actions';
@@ -16,13 +17,15 @@ export const SearchSectionResultItem = React.forwardRef(function SearchSectionRe
ref: React.Ref
) {
const { query, item, active } = props;
+ const language = useLanguage();
return (
) : null}
+ )}
);
});
diff --git a/packages/gitbook/src/intl/translations/en.ts b/packages/gitbook/src/intl/translations/en.ts
index df9cc5099..2e792b121 100644
--- a/packages/gitbook/src/intl/translations/en.ts
+++ b/packages/gitbook/src/intl/translations/en.ts
@@ -6,6 +6,7 @@ export const en = {
switch_to_light_theme: 'Switch to light theme',
switch_to_system_theme: 'Switch to system theme',
search: 'Search',
+ view: 'View',
search_or_ask: 'Ask or search',
search_input_placeholder: 'Search content',
search_ask_input_placeholder: 'Search content or ask a question',