From 53d2c7d4e5997a56ac21bd3a3d6991da661fcc2f Mon Sep 17 00:00:00 2001 From: mimurawil Date: Thu, 9 Jan 2025 08:27:12 -0800 Subject: [PATCH 01/15] use algolia search package --- .env.example | 4 +- package-lock.json | 76 +++++++++++++++++++++++ package.json | 1 + src/components/Header/aiSearch/Search.tsx | 14 ++--- 4 files changed, 86 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index 0fc57dd934c..bf2727b66ea 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,5 @@ ALGOLIA_APP_ID=I9A62UQS9Z ALGOLIA_WRITE_API_KEY= -ALGOLIA_INDEX_NAME=docs-test \ No newline at end of file +ALGOLIA_INDEX_NAME=docs-test +PUBLIC_ALGOLIA_SEARCH_APP_ID= +PUBlIC_ALGOLIA_SEARCH_PUBLIC_API_KEY= diff --git a/package-lock.json b/package-lock.json index cf1c00ad332..16b9d44a86b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,6 +32,7 @@ "@openzeppelin/contracts": "^4.9.6", "astro": "^4.15.1", "bignumber.js": "^9.1.2", + "chainlink-algolia-search": "^0.1.0", "clipboard": "^2.0.11", "dotenv": "^16.4.5", "ethers": "^5.7.2", @@ -291,6 +292,25 @@ "node": ">= 14.0.0" } }, + "node_modules/@algolia/requester-fetch": { + "version": "5.19.0", + "resolved": "https://registry.npmjs.org/@algolia/requester-fetch/-/requester-fetch-5.19.0.tgz", + "integrity": "sha512-oyTt8ZJ4T4fYvW5avAnuEc6Laedcme9fAFryMD9ndUTIUe/P0kn3BuGcCLFjN3FDmdrETHSFkgPPf1hGy3sLCw==", + "dependencies": { + "@algolia/client-common": "5.19.0" + }, + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/@algolia/requester-fetch/node_modules/@algolia/client-common": { + "version": "5.19.0", + "resolved": "https://registry.npmjs.org/@algolia/client-common/-/client-common-5.19.0.tgz", + "integrity": "sha512-2ERRbICHXvtj5kfFpY5r8qu9pJII/NAHsdgUXnUitQFwPdPL7wXiupcvZJC7DSntOnE8AE0lM7oDsPhrJfj5nQ==", + "engines": { + "node": ">= 14.0.0" + } + }, "node_modules/@algolia/requester-node-http": { "version": "5.11.0", "resolved": "https://registry.npmjs.org/@algolia/requester-node-http/-/requester-node-http-5.11.0.tgz", @@ -12782,6 +12802,62 @@ "chai": ">= 2.1.2 < 6" } }, + "node_modules/chainlink-algolia-search": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/chainlink-algolia-search/-/chainlink-algolia-search-0.1.0.tgz", + "integrity": "sha512-+/umzEtRevywa4ElX2VqVX2SPEhz7EWanJCzWFowNvLIITVREOGPhE4vTVm8nfKWYoQUGiTB4M9LI1v5feF5OA==", + "dependencies": { + "@algolia/client-search": "^5.17.1" + }, + "peerDependencies": { + "react": ">=18.0.0", + "react-dom": ">=18.0.0" + } + }, + "node_modules/chainlink-algolia-search/node_modules/@algolia/client-common": { + "version": "5.19.0", + "resolved": "https://registry.npmjs.org/@algolia/client-common/-/client-common-5.19.0.tgz", + "integrity": "sha512-2ERRbICHXvtj5kfFpY5r8qu9pJII/NAHsdgUXnUitQFwPdPL7wXiupcvZJC7DSntOnE8AE0lM7oDsPhrJfj5nQ==", + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/chainlink-algolia-search/node_modules/@algolia/client-search": { + "version": "5.19.0", + "resolved": "https://registry.npmjs.org/@algolia/client-search/-/client-search-5.19.0.tgz", + "integrity": "sha512-Ctg3xXD/1VtcwmkulR5+cKGOMj4r0wC49Y/KZdGQcqpydKn+e86F6l3tb3utLJQVq4lpEJud6kdRykFgcNsp8Q==", + "dependencies": { + "@algolia/client-common": "5.19.0", + "@algolia/requester-browser-xhr": "5.19.0", + "@algolia/requester-fetch": "5.19.0", + "@algolia/requester-node-http": "5.19.0" + }, + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/chainlink-algolia-search/node_modules/@algolia/requester-browser-xhr": { + "version": "5.19.0", + "resolved": "https://registry.npmjs.org/@algolia/requester-browser-xhr/-/requester-browser-xhr-5.19.0.tgz", + "integrity": "sha512-GfnhnQBT23mW/VMNs7m1qyEyZzhZz093aY2x8p0era96MMyNv8+FxGek5pjVX0b57tmSCZPf4EqNCpkGcGsmbw==", + "dependencies": { + "@algolia/client-common": "5.19.0" + }, + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/chainlink-algolia-search/node_modules/@algolia/requester-node-http": { + "version": "5.19.0", + "resolved": "https://registry.npmjs.org/@algolia/requester-node-http/-/requester-node-http-5.19.0.tgz", + "integrity": "sha512-p6t8ue0XZNjcRiqNkb5QAM0qQRAKsCiebZ6n9JjWA+p8fWf8BvnhO55y2fO28g3GW0Imj7PrAuyBuxq8aDVQwQ==", + "dependencies": { + "@algolia/client-common": "5.19.0" + }, + "engines": { + "node": ">= 14.0.0" + } + }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", diff --git a/package.json b/package.json index 809b32263dc..ad25ae1f309 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "@openzeppelin/contracts": "^4.9.6", "astro": "^4.15.1", "bignumber.js": "^9.1.2", + "chainlink-algolia-search": "^0.1.0", "clipboard": "^2.0.11", "dotenv": "^16.4.5", "ethers": "^5.7.2", diff --git a/src/components/Header/aiSearch/Search.tsx b/src/components/Header/aiSearch/Search.tsx index 6fc49bbe298..b5d01fb8245 100644 --- a/src/components/Header/aiSearch/Search.tsx +++ b/src/components/Header/aiSearch/Search.tsx @@ -1,11 +1,9 @@ -import { SearchButton } from "./SearchButton" -import { SearchModal } from "./SearchModal" +import { SearchButton } from "chainlink-algolia-search" +import "chainlink-algolia-search/dist/index.css" + +const algoliaAppId = import.meta.env.PUBLIC_ALGOLIA_SEARCH_APP_ID || "" +const algoliaPublicApiKey = import.meta.env.PUBLIC_ALGOLIA_SEARCH_PUBLIC_API_KEY || "" export const Search = () => { - return ( - <> - - - - ) + return } From c7d11aa21c75d1fdaea9bd40fd8f05d7fe185280 Mon Sep 17 00:00:00 2001 From: mimurawil Date: Thu, 9 Jan 2025 08:31:55 -0800 Subject: [PATCH 02/15] fix env var name in .env.example --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index bf2727b66ea..c91f7e7ae73 100644 --- a/.env.example +++ b/.env.example @@ -2,4 +2,4 @@ ALGOLIA_APP_ID=I9A62UQS9Z ALGOLIA_WRITE_API_KEY= ALGOLIA_INDEX_NAME=docs-test PUBLIC_ALGOLIA_SEARCH_APP_ID= -PUBlIC_ALGOLIA_SEARCH_PUBLIC_API_KEY= +PUBLIC_ALGOLIA_SEARCH_PUBLIC_API_KEY= From 76e8441f8435e25eac0f7f4e30bfc4809ff207fb Mon Sep 17 00:00:00 2001 From: mimurawil Date: Thu, 9 Jan 2025 08:46:26 -0800 Subject: [PATCH 03/15] fix env var typescript --- src/components/Header/Header.astro | 6 +++++- src/components/Header/NavBar.tsx | 12 ++++++++++-- src/components/Header/aiSearch/Search.tsx | 9 +++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/components/Header/Header.astro b/src/components/Header/Header.astro index 747ad3924fd..1f2af198af0 100644 --- a/src/components/Header/Header.astro +++ b/src/components/Header/Header.astro @@ -3,6 +3,10 @@ import NotificationBanner from "~/features/notifications/components/Notification import { NavBar } from "./NavBar" const path = Astro.url.pathname +const algoliaVars = { + algoliaAppId: import.meta.env.PUBLIC_ALGOLIA_SEARCH_APP_ID || "", + algoliaPublicApiKey: import.meta.env.PUBLIC_ALGOLIA_SEARCH_PUBLIC_API_KEY || "", +} --- @@ -12,6 +16,6 @@ const path = Astro.url.pathname width="0" style="display:none;visibility:hidden"> - + diff --git a/src/components/Header/NavBar.tsx b/src/components/Header/NavBar.tsx index 709d0714a94..0542b8f44f1 100644 --- a/src/components/Header/NavBar.tsx +++ b/src/components/Header/NavBar.tsx @@ -5,7 +5,15 @@ import { getNavigationProps } from "./getNavigationProps" import { useNavBar } from "./useNavBar/useNavBar" import styles from "./scroll.module.css" -export const NavBar = ({ path, showSearch = true }: { path: string; showSearch?: boolean }) => { +export const NavBar = ({ + path, + showSearch = true, + algoliaVars, +}: { + path: string + showSearch?: boolean + algoliaVars: { algoliaAppId: string; algoliaPublicApiKey: string } +}) => { const navRef = React.useRef(null) const { setNavBarInfo } = useNavBar() @@ -47,7 +55,7 @@ export const NavBar = ({ path, showSearch = true }: { path: string; showSearch?: