forked from vanilla-extract-css/vanilla-extract
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearchInput.tsx
More file actions
36 lines (30 loc) · 1.07 KB
/
SearchInput.tsx
File metadata and controls
36 lines (30 loc) · 1.07 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
import { DocSearch } from '@docsearch/react';
import '@docsearch/css';
import { ComponentProps } from 'react';
import './SearchInput.css';
type DocSearchProps = ComponentProps<typeof DocSearch>;
// Make search item URLs relative so the local site doesn't take you back to prod
const transformSearchResultItems: DocSearchProps['transformItems'] = (items) =>
items.map((item) => {
const url = new URL(item.url);
return {
...item,
url: `${url.pathname}${url.hash}`,
};
});
const getMissingResultsUrl: DocSearchProps['getMissingResultsUrl'] = ({
query,
}) =>
`https://github.com/vanilla-extract-css/vanilla-extract/issues/new?assignees=&labels=pending+triage&template=bug_report.yml&bug-description=Search query \`${encodeURIComponent(
query,
)}\` should return search results.`;
export const SearchInput = () => (
<DocSearch
appId="ABPL1AJSFN"
apiKey="d0d2252fbd30f7cb523a50c5a7780078"
indexName="vanilla-extract"
transformItems={transformSearchResultItems}
getMissingResultsUrl={getMissingResultsUrl}
placeholder="Search"
/>
);