-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathindex.tsx
More file actions
49 lines (42 loc) · 1.43 KB
/
index.tsx
File metadata and controls
49 lines (42 loc) · 1.43 KB
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
40
41
42
43
44
45
46
47
48
49
import { ChatInteractions } from '@orama/ui/components';
import type { Document } from '../DocumentLink';
import type { Interaction, AnyObject } from '@orama/core';
import type { FC } from 'react';
import { DocumentLink } from '../DocumentLink';
import styles from './index.module.css';
type ChatSourcesProps = {
interaction: Interaction;
};
const ChatSources: FC<ChatSourcesProps> = ({ interaction }) => {
if (!interaction?.sources) {
return null;
}
return (
<ChatInteractions.Sources
interaction={interaction}
className={styles.chatSources}
itemClassName={styles.chatSourceItem}
>
{(document: AnyObject, index: number) => (
<div className={styles.chatSource} key={index}>
{!!document.pageSectionTitle &&
typeof document.pageSectionTitle === 'string' && (
<DocumentLink
document={document as Document}
className={styles.chatSourceLink}
data-focus-on-arrow-nav
>
<span className={styles.chatSourceTitle}>
{document.pageSectionTitle &&
document.pageSectionTitle.length > 25
? `${document.pageSectionTitle.substring(0, 25)}...`
: document.pageSectionTitle}
</span>
</DocumentLink>
)}
</div>
)}
</ChatInteractions.Sources>
);
};
export default ChatSources;