diff --git a/site/source/components/search/Algolia.ts b/site/source/components/search/Algolia.ts new file mode 100644 index 000000000..31d936b89 --- /dev/null +++ b/site/source/components/search/Algolia.ts @@ -0,0 +1,9 @@ +import algoliasearch from 'algoliasearch/lite' + +const ALGOLIA_APP_ID = import.meta.env.VITE_ALGOLIA_APP_ID || '' +const ALGOLIA_SEARCH_KEY = import.meta.env.VITE_ALGOLIA_SEARCH_KEY || '' + +export const searchClient = algoliasearch(ALGOLIA_APP_ID, ALGOLIA_SEARCH_KEY) + +export const algoliaIndexPrefix = + import.meta.env.VITE_ALGOLIA_INDEX_PREFIX || '' diff --git a/site/source/components/search/SearchRules.tsx b/site/source/components/search/SearchRules.tsx index dc7fec360..00bdefedf 100644 --- a/site/source/components/search/SearchRules.tsx +++ b/site/source/components/search/SearchRules.tsx @@ -1,24 +1,18 @@ -import algoliasearch from 'algoliasearch/lite' import { Trans, useTranslation } from 'react-i18next' import { H2 } from '@/design-system/typography/heading' +import { algoliaIndexPrefix, searchClient } from './Algolia' import { RulesInfiniteHits } from './RulesInfiniteHits' import { SearchBox } from './SearchBox' import { SearchRoot } from './SearchRoot' -const ALGOLIA_APP_ID = import.meta.env.VITE_ALGOLIA_APP_ID || '' -const ALGOLIA_SEARCH_KEY = import.meta.env.VITE_ALGOLIA_SEARCH_KEY || '' -const ALGOLIA_INDEX_PREFIX = import.meta.env.VITE_ALGOLIA_INDEX_PREFIX || '' - -const searchClient = algoliasearch(ALGOLIA_APP_ID, ALGOLIA_SEARCH_KEY) - export default function SearchRules() { const { t } = useTranslation() return ( void } @@ -36,7 +30,7 @@ export default function SearchRulesAndSimulators({ closePopover }: Props) { return ( @@ -45,12 +39,12 @@ export default function SearchRulesAndSimulators({ closePopover }: Props) { aria-label={t('Rechercher un simulateur ou une règle')} /> - + - +