diff --git a/package-lock.json b/package-lock.json index 47fc793d975686f..be5355d2380edfa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,8 +53,6 @@ "globals": "16.0.0", "hastscript": "9.0.1", "he": "1.2.0", - "instantsearch.css": "8.5.1", - "instantsearch.js": "4.78.0", "jsonc-parser": "3.3.1", "lz-string": "1.5.0", "marked": "15.0.7", @@ -70,6 +68,7 @@ "react": "19.0.0", "react-dom": "19.0.0", "react-icons": "5.5.0", + "react-instantsearch": "7.15.4", "react-markdown": "10.0.1", "redirects-in-workers": "0.0.5", "rehype": "13.0.2", @@ -10736,13 +10735,6 @@ "@babel/runtime": "^7.1.2" } }, - "node_modules/instantsearch.css": { - "version": "8.5.1", - "resolved": "https://registry.npmjs.org/instantsearch.css/-/instantsearch.css-8.5.1.tgz", - "integrity": "sha512-lu4gWSa2crIA1OAuFwtrNJy4d8oRvKmkY5gv8Dbf3tuedQMm6cf7K+1kXJKRAHLm4pZos9RXIH10m57UfDKbyg==", - "dev": true, - "license": "MIT" - }, "node_modules/instantsearch.js": { "version": "4.78.0", "resolved": "https://registry.npmjs.org/instantsearch.js/-/instantsearch.js-4.78.0.tgz", @@ -14856,6 +14848,41 @@ "react": "*" } }, + "node_modules/react-instantsearch": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/react-instantsearch/-/react-instantsearch-7.15.4.tgz", + "integrity": "sha512-gr2oxOXPmMirFgTVYRo//Lr0wXMOYdcOiybJxRzA/jAN/5Hom+COt/wCgBmH8yH1RNIqjN+y6k86wXzH08HAww==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.1.2", + "instantsearch-ui-components": "0.11.1", + "instantsearch.js": "4.78.0", + "react-instantsearch-core": "7.15.4" + }, + "peerDependencies": { + "algoliasearch": ">= 3.1 < 6", + "react": ">= 16.8.0 < 20", + "react-dom": ">= 16.8.0 < 20" + } + }, + "node_modules/react-instantsearch-core": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/react-instantsearch-core/-/react-instantsearch-core-7.15.4.tgz", + "integrity": "sha512-s2PPiAhQbamWoxSttxyfg4TKVteiEVkpmyYE7ef/6yoAO3QXVLZH5XsrqxBBLpH8XcpheuGYD3HvI/dhyUKYxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.1.2", + "algoliasearch-helper": "3.24.2", + "instantsearch.js": "4.78.0", + "use-sync-external-store": "^1.0.0" + }, + "peerDependencies": { + "algoliasearch": ">= 3.1 < 6", + "react": ">= 16.8.0 < 20" + } + }, "node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", @@ -18053,6 +18080,16 @@ "punycode": "^2.1.0" } }, + "node_modules/use-sync-external-store": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.4.0.tgz", + "integrity": "sha512-9WXSPC5fMv61vaupRkCKCxsPxBocVnwakBEkMIHHpkTTg6icbJtg6jzgtLDm4bl3cSHAca52rYWih0k4K3PfHw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/package.json b/package.json index 907b35c759a7363..2b693b5b5f1d394 100644 --- a/package.json +++ b/package.json @@ -71,8 +71,6 @@ "globals": "16.0.0", "hastscript": "9.0.1", "he": "1.2.0", - "instantsearch.css": "8.5.1", - "instantsearch.js": "4.78.0", "jsonc-parser": "3.3.1", "lz-string": "1.5.0", "marked": "15.0.7", @@ -88,6 +86,7 @@ "react": "19.0.0", "react-dom": "19.0.0", "react-icons": "5.5.0", + "react-instantsearch": "7.15.4", "react-markdown": "10.0.1", "redirects-in-workers": "0.0.5", "rehype": "13.0.2", diff --git a/src/components/search/InstantSearch.tsx b/src/components/search/InstantSearch.tsx new file mode 100644 index 000000000000000..42d050f87592f8c --- /dev/null +++ b/src/components/search/InstantSearch.tsx @@ -0,0 +1,95 @@ +import { liteClient as algoliasearch } from "algoliasearch/lite"; +import { useEffect } from "react"; +import { + InstantSearch, + Highlight, + Configure, + useSearchBox, + type UseSearchBoxProps, + useInfiniteHits, + type UseInfiniteHitsProps, +} from "react-instantsearch"; + +function SearchBox(props: UseSearchBoxProps) { + const { query, refine } = useSearchBox(props); + + useEffect(() => { + const params = new URLSearchParams(window.location.search); + const query = params.get("query"); + + if (query) { + refine(query); + } + }, []); + + return ( +
+