-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathindex.tsx
More file actions
36 lines (30 loc) · 951 Bytes
/
index.tsx
File metadata and controls
36 lines (30 loc) · 951 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
import SearchHit from '@node-core/ui-components/Common/Search/Results/Hit';
import Link from 'next/link';
import { useLocale } from 'next-intl';
import type { Document } from '../DocumentLink';
import type { LinkLike } from '@node-core/ui-components/types';
import type { ComponentProps, FC } from 'react';
import { getDocumentHref, getFormattedPath } from './utils';
type SearchItemProps = Omit<
ComponentProps<typeof SearchHit>,
'document' | 'as'
> & {
document: Document;
};
const SearchItem: FC<SearchItemProps> = ({ document, ...props }) => {
const locale = useLocale();
return (
<SearchHit
document={{
title: document.pageSectionTitle,
description:
document.pageSectionTitle &&
getFormattedPath(document.path, document.pageSectionTitle),
href: getDocumentHref(document, locale),
}}
as={Link as LinkLike}
{...props}
/>
);
};
export default SearchItem;