Skip to content

Commit

Permalink
[DO NOT MERGE] Test algolia search (#2248)
Browse files Browse the repository at this point in the history
* use algolia search package

* fix env var name in .env.example

* fix env var typescript

* remove unused old search components

* search button should always show now on mobile and desktop

* Update Algolia search package

* Update package to 0.3

* Update Package.lock

* Update algolia search to version 0.4.2

* Update Search Preview

* Update fallback image

* Update Search package to 0.6.3

* Update to algolia 0.7

* Add Specific links and upgrade to V 0.8

* Version 0.8.3

* Version 0.8.4

* revert change on icon

---------

Co-authored-by: Simone Cuomo <simone@thisdot.co>
  • Loading branch information
mimurawil and Zelig880 authored Jan 31, 2025
1 parent 2da0b59 commit 4ce03ef
Show file tree
Hide file tree
Showing 13 changed files with 227 additions and 218 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ALGOLIA_APP_ID=I9A62UQS9Z
ALGOLIA_WRITE_API_KEY=
ALGOLIA_INDEX_NAME=docs-test
ALGOLIA_INDEX_NAME=docs-test
PUBLIC_ALGOLIA_SEARCH_APP_ID=
PUBLIC_ALGOLIA_SEARCH_PUBLIC_API_KEY=
195 changes: 189 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@openzeppelin/contracts": "^4.9.6",
"astro": "^4.15.1",
"bignumber.js": "^9.1.2",
"chainlink-algolia-search": "^0.8.4",
"clipboard": "^2.0.11",
"dotenv": "^16.4.5",
"ethers": "^5.7.2",
Expand Down
Binary file added public/images/algolia/quick-start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/algolia/tools.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion src/components/Header/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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 || "",
}
---

<!-- Google Tag Manager (noscript) -->
Expand All @@ -12,6 +16,6 @@ const path = Astro.url.pathname
width="0"
style="display:none;visibility:hidden"></iframe>
<!-- End Google Tag Manager (noscript) -->
<NavBar path={path} client:idle />
<NavBar path={path} client:idle algoliaVars={algoliaVars} />

<NotificationBanner />
4 changes: 0 additions & 4 deletions src/components/Header/Nav/navBar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,6 @@
fill: var(--color-text-primary);
}

.searchTrigger {
display: initial;
}

.rightSection {
justify-content: flex-end;
}
Expand Down
12 changes: 10 additions & 2 deletions src/components/Header/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -47,7 +55,7 @@ export const NavBar = ({ path, showSearch = true }: { path: string; showSearch?:
<Nav
{...getNavigationProps()}
path={path}
searchTrigger={showSearch ? <Search /> : undefined}
searchTrigger={showSearch ? <Search algoliaVars={algoliaVars} /> : undefined}
onHideChange={onHideChange}
doubleNavbar={doubleNavbar()}
/>
Expand Down
26 changes: 19 additions & 7 deletions src/components/Header/aiSearch/Search.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { SearchButton } from "./SearchButton"
import { SearchModal } from "./SearchModal"
import { SearchButton } from "chainlink-algolia-search"
import "chainlink-algolia-search/dist/index.css"

export const Search = () => {
export const Search = ({
algoliaVars: { algoliaAppId, algoliaPublicApiKey },
}: {
algoliaVars: { algoliaAppId: string; algoliaPublicApiKey: string }
}) => {
return (
<>
<SearchButton />
<SearchModal />
</>
<SearchButton
algoliaAppId={algoliaAppId}
algoliaPublicApiKey={algoliaPublicApiKey}
popularCards={[
{
url: "https://dev.chain.link/resources/quickstarts",
imgSrc: "/images/algolia/quick-start.png",
label: "Quickstarts",
},
{ url: "https://dev.chain.link/tools", imgSrc: "/images/algolia/tools.png", label: "Tools" },
]}
/>
)
}
Loading

0 comments on commit 4ce03ef

Please sign in to comment.