-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathindex.tsx
More file actions
39 lines (34 loc) · 1001 Bytes
/
index.tsx
File metadata and controls
39 lines (34 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { DocumentTextIcon } from '@heroicons/react/24/outline';
import { SearchResults } from '@orama/ui/components';
import type { LinkLike } from '#ui/types';
import type { FC } from 'react';
import styles from './index.module.css';
type HitProps = {
document: {
title?: string;
description?: string;
href: string;
};
mode?: 'search' | 'chat';
as?: LinkLike;
};
const Hit: FC<HitProps> = ({ document, mode = 'search', as: Link = 'a' }) => (
<SearchResults.Item>
<Link
href={document.href}
tabIndex={mode === 'search' ? 0 : -1}
aria-hidden={mode === 'chat'}
data-focus-on-arrow-nav
className={styles.link}
>
<DocumentTextIcon />
<div>
{typeof document?.title === 'string' && <h3>{document.title}</h3>}
{typeof document?.description === 'string' && (
<p className={styles.hitDescription}>{document.description}</p>
)}
</div>
</Link>
</SearchResults.Item>
);
export default Hit;