Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Test algolia search #2248

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
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.7.0",
"clipboard": "^2.0.11",
"dotenv": "^16.4.5",
"ethers": "^5.7.2",
Expand Down
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
17 changes: 8 additions & 9 deletions src/components/Header/aiSearch/Search.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { SearchButton } from "./SearchButton"
import { SearchModal } from "./SearchModal"
import { SearchButton } from "chainlink-algolia-search"
import "chainlink-algolia-search/dist/index.css"

export const Search = () => {
return (
<>
<SearchButton />
<SearchModal />
</>
)
export const Search = ({
algoliaVars: { algoliaAppId, algoliaPublicApiKey },
}: {
algoliaVars: { algoliaAppId: string; algoliaPublicApiKey: string }
}) => {
return <SearchButton algoliaAppId={algoliaAppId} algoliaPublicApiKey={algoliaPublicApiKey} />
}
Loading
Loading