This commit is contained in:
Robert Jelic
2025-02-16 18:04:24 +01:00
parent 41e6149828
commit 31787b0e9b
2670 changed files with 1037781 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import algoliasearch from 'algoliasearch/dist/algoliasearch-lite.esm.browser';
import React from 'react';
import { version } from './version';
export function useSearchClient(appId, apiKey, transformSearchClient) {
var searchClient = React.useMemo(function () {
var client = algoliasearch(appId, apiKey);
client.addAlgoliaAgent('docsearch', version); // Since DocSearch.js relies on DocSearch React with an alias to Preact,
// we cannot add the `docsearch-react` user agent by default, otherwise
// it would also be sent on a DocSearch.js integration.
// We therefore only add the `docsearch-react` user agent if `docsearch.js`
// is not present.
if (/docsearch.js \(.*\)/.test(client.transporter.userAgent.value) === false) {
client.addAlgoliaAgent('docsearch-react', version);
}
return transformSearchClient(client);
}, [appId, apiKey, transformSearchClient]);
return searchClient;
}