22
33import { DocumentTextIcon } from '@heroicons/react/24/outline' ;
44import { SearchResults } from '@orama/ui/components' ;
5- import { useReducer , type FC } from 'react' ;
6-
7- import searchReducer , { searchState } from '#site/reducers/searchboxReducer' ;
5+ import type { FC } from 'react' ;
86
97import { DocumentLink } from '../DocumentLink' ;
108import type { Document } from '../DocumentLink' ;
@@ -13,32 +11,29 @@ import { getFormattedPath } from './utils';
1311
1412type SearchItemProps = {
1513 document : Document ;
14+ mode ?: 'search' | 'chat' ;
1615} ;
1716
18- export const SearchItem : FC < SearchItemProps > = ( { document } ) => {
19- const [ state ] = useReducer ( searchReducer , searchState ) ;
20- const isSearchMode = state . mode === 'search' ;
21- return (
22- < SearchResults . Item className = { styles . searchResultsItem } >
23- < DocumentLink
24- document = { document as Document }
25- tabIndex = { isSearchMode ? 0 : - 1 }
26- aria-hidden = { ! isSearchMode }
27- data-focus-on-arrow-nav
28- >
29- < DocumentTextIcon />
30- < div >
31- { typeof document ?. pageSectionTitle === 'string' && (
32- < h3 > { document . pageSectionTitle } </ h3 >
17+ export const SearchItem : FC < SearchItemProps > = ( { document, mode } ) => (
18+ < SearchResults . Item className = { styles . searchResultsItem } >
19+ < DocumentLink
20+ document = { document as Document }
21+ tabIndex = { mode === 'search' ? 0 : - 1 }
22+ aria-hidden = { mode === 'chat' }
23+ data-focus-on-arrow-nav
24+ >
25+ < DocumentTextIcon />
26+ < div >
27+ { typeof document ?. pageSectionTitle === 'string' && (
28+ < h3 > { document . pageSectionTitle } </ h3 >
29+ ) }
30+ { typeof document ?. pageSectionTitle === 'string' &&
31+ typeof document ?. path === 'string' && (
32+ < p className = { styles . searchResultsItemDescription } >
33+ { getFormattedPath ( document . path , document . pageSectionTitle ) }
34+ </ p >
3335 ) }
34- { typeof document ?. pageSectionTitle === 'string' &&
35- typeof document ?. path === 'string' && (
36- < p className = { styles . searchResultsItemDescription } >
37- { getFormattedPath ( document . path , document . pageSectionTitle ) }
38- </ p >
39- ) }
40- </ div >
41- </ DocumentLink >
42- </ SearchResults . Item >
43- ) ;
44- } ;
36+ </ div >
37+ </ DocumentLink >
38+ </ SearchResults . Item >
39+ ) ;
0 commit comments