({
result,
resultIndex,
autocomplete,
collection,
query
}: {
result: Result;
resultIndex: number;
autocomplete: Autocomplete;
collection: AutocompleteCollection<Result>;
query: string;
})
| 163 | } |
| 164 | |
| 165 | function SearchResult({ |
| 166 | result, |
| 167 | resultIndex, |
| 168 | autocomplete, |
| 169 | collection, |
| 170 | query |
| 171 | }: { |
| 172 | result: Result; |
| 173 | resultIndex: number; |
| 174 | autocomplete: Autocomplete; |
| 175 | collection: AutocompleteCollection<Result>; |
| 176 | query: string; |
| 177 | }) { |
| 178 | let id = useId(); |
| 179 | |
| 180 | let sectionTitle = navigationData.find(section => |
| 181 | section.links.find(link => link.href === result.url.split('#')[0]) |
| 182 | )?.title; |
| 183 | let hierarchy = [sectionTitle, result.pageTitle].filter( |
| 184 | (x): x is string => typeof x === 'string' |
| 185 | ); |
| 186 | |
| 187 | return ( |
| 188 | <li |
| 189 | className={clsx( |
| 190 | 'group block cursor-default px-4 py-3 aria-selected:bg-zinc-50 dark:aria-selected:bg-zinc-800/50', |
| 191 | resultIndex > 0 && |
| 192 | 'border-t border-zinc-100 dark:border-zinc-800' |
| 193 | )} |
| 194 | aria-labelledby={`${id}-hierarchy ${id}-title`} |
| 195 | {...autocomplete.getItemProps({ |
| 196 | item: result, |
| 197 | source: collection.source |
| 198 | })} |
| 199 | > |
| 200 | <div |
| 201 | id={`${id}-title`} |
| 202 | aria-hidden="true" |
| 203 | className="text-sm font-medium text-[#19182E] dark:text-white dark:group-aria-selected:text-[#fad000]" |
| 204 | > |
| 205 | <HighlightQuery text={result.title} query={query} /> |
| 206 | </div> |
| 207 | {hierarchy.length > 0 && ( |
| 208 | <div |
| 209 | id={`${id}-hierarchy`} |
| 210 | aria-hidden="true" |
| 211 | className="mt-1 truncate whitespace-nowrap text-2xs text-zinc-500" |
| 212 | > |
| 213 | {hierarchy.map((item, itemIndex, items) => ( |
| 214 | <Fragment key={itemIndex}> |
| 215 | <HighlightQuery text={item} query={query} /> |
| 216 | <span |
| 217 | className={ |
| 218 | itemIndex === items.length - 1 |
| 219 | ? 'sr-only' |
| 220 | : 'mx-2 text-zinc-300 dark:text-zinc-700' |
| 221 | } |
| 222 | > |
nothing calls this directly
no outgoing calls
no test coverage detected