Skip to content

Commit 827fab7

Browse files
committed
fix env var typescript
1 parent bd7e987 commit 827fab7

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

src/components/Header/Header.astro

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import NotificationBanner from "~/features/notifications/components/Notification
33
import { NavBar } from "./NavBar"
44
55
const path = Astro.url.pathname
6+
const algoliaVars = {
7+
algoliaAppId: import.meta.env.PUBLIC_ALGOLIA_SEARCH_APP_ID || "",
8+
algoliaPublicApiKey: import.meta.env.PUBLIC_ALGOLIA_SEARCH_PUBLIC_API_KEY || "",
9+
}
610
---
711

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

1721
<NotificationBanner />

src/components/Header/NavBar.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ import { getNavigationProps } from "./getNavigationProps"
55
import { useNavBar } from "./useNavBar/useNavBar"
66
import styles from "./scroll.module.css"
77

8-
export const NavBar = ({ path, showSearch = true }: { path: string; showSearch?: boolean }) => {
8+
export const NavBar = ({
9+
path,
10+
showSearch = true,
11+
algoliaVars,
12+
}: {
13+
path: string
14+
showSearch?: boolean
15+
algoliaVars: { algoliaAppId: string; algoliaPublicApiKey: string }
16+
}) => {
917
const navRef = React.useRef(null)
1018

1119
const { setNavBarInfo } = useNavBar()
@@ -47,7 +55,7 @@ export const NavBar = ({ path, showSearch = true }: { path: string; showSearch?:
4755
<Nav
4856
{...getNavigationProps()}
4957
path={path}
50-
searchTrigger={showSearch ? <Search /> : undefined}
58+
searchTrigger={showSearch ? <Search algoliaVars={algoliaVars} /> : undefined}
5159
onHideChange={onHideChange}
5260
doubleNavbar={doubleNavbar()}
5361
/>
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { SearchButton } from "chainlink-algolia-search"
22
import "chainlink-algolia-search/dist/index.css"
33

4-
const algoliaAppId = import.meta.env.PUBLIC_ALGOLIA_SEARCH_APP_ID || ""
5-
const algoliaPublicApiKey = import.meta.env.PUBLIC_ALGOLIA_SEARCH_PUBLIC_API_KEY || ""
6-
7-
export const Search = ({ variant = "default" }: { variant?: "default" | "mobile" }) => {
4+
export const Search = ({
5+
variant = "default",
6+
algoliaVars: { algoliaAppId, algoliaPublicApiKey },
7+
}: {
8+
variant?: "default" | "mobile"
9+
algoliaVars: { algoliaAppId: string; algoliaPublicApiKey: string }
10+
}) => {
811
return <SearchButton algoliaAppId={algoliaAppId} algoliaPublicApiKey={algoliaPublicApiKey} />
912
}

0 commit comments

Comments
 (0)