mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-16 01:01:38 +00:00
* 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
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { FC } from 'react';
|
|
import algoliasearch from 'algoliasearch/lite';
|
|
import { InstantSearch } from 'react-instantsearch-dom';
|
|
import {
|
|
Flex,
|
|
Modal,
|
|
ModalBody,
|
|
ModalCloseButton,
|
|
ModalContent,
|
|
ModalOverlay,
|
|
} from '@chakra-ui/react';
|
|
import CustomSearchBox from './CustomSearchBox';
|
|
import CustomHits from './CustomHits';
|
|
|
|
const searchClient = algoliasearch(
|
|
process.env.NEXT_PUBLIC_ALGOLIA_APP_ID ?? '',
|
|
process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY ?? ''
|
|
);
|
|
|
|
interface Props {
|
|
isModalOpen: boolean;
|
|
onModalClose: () => void;
|
|
}
|
|
|
|
const Search: FC<Props> = ({ isModalOpen, onModalClose }) => {
|
|
return (
|
|
<>
|
|
<Modal size="xl" isOpen={isModalOpen} onClose={onModalClose}>
|
|
<ModalOverlay />
|
|
<ModalContent>
|
|
<ModalBody p="0.5rem">
|
|
<InstantSearch searchClient={searchClient} indexName="rua">
|
|
<Flex justifyContent="space-between" alignItems="center">
|
|
<CustomSearchBox />
|
|
<ModalCloseButton
|
|
position="unset"
|
|
display={[null, null, 'none']}
|
|
/>
|
|
</Flex>
|
|
|
|
<CustomHits />
|
|
</InstantSearch>
|
|
</ModalBody>
|
|
</ModalContent>
|
|
</Modal>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default Search;
|