Files
DefectingCat.github.io/components/search/CustomSearchBox.tsx
DefectingCat 9460f7569c Add algoliasearch
* add menu item
* add pages
* add build search script

Add custom algolia component
* fix image in post width

Delete useless file

Modify post data to algolia script
2021-11-29 23:10:33 +08:00

32 lines
804 B
TypeScript

import { FC } from 'react';
import { connectSearchBox } from 'react-instantsearch-dom';
import { SearchBoxProvided } from 'react-instantsearch-core';
import {
InputGroup,
Input,
InputRightElement,
CloseButton,
} from '@chakra-ui/react';
const SearchBox: FC<SearchBoxProvided> = ({ currentRefinement, refine }) => {
return (
<>
<InputGroup>
<Input
value={currentRefinement}
onChange={(event) => refine(event.currentTarget.value)}
autoFocus
placeholder="Seach posts..."
/>
<InputRightElement>
{currentRefinement && <CloseButton onClick={() => refine('')} />}
</InputRightElement>
</InputGroup>
</>
);
};
const CustomSearchBox = connectSearchBox(SearchBox);
export default CustomSearchBox;