Skip to content

Commit

Permalink
Add @docsearch/react package and integrate AlgoliaSearch component in…
Browse files Browse the repository at this point in the history
…to header.astro
  • Loading branch information
dharamveergit committed May 2, 2024
1 parent d564320 commit 8a41430
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 11 deletions.
1 change: 1 addition & 0 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 @@ -17,6 +17,7 @@
"@astrojs/tailwind": "^5.0.4",
"@docsearch/css": "^3.6.0",
"@docsearch/js": "^3.6.0",
"@docsearch/react": "^3.6.0",
"@fontsource-variable/jetbrains-mono": "^5.0.18",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
Expand Down
15 changes: 15 additions & 0 deletions src/components/docs/algolia-search.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";
import { DocSearch } from "@docsearch/react";
import "@docsearch/css";
import "../../styles/globals.css";
const AlgoliaSearch = () => {
return (
<DocSearch
appId="GIAYK50IZ2"
apiKey="ab27356463ffa13e3d75727cd71bfc69"
indexName="akash"
/>
);
};

export default AlgoliaSearch;
8 changes: 5 additions & 3 deletions src/components/docs/header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import AkashDocsLogo from "./akash-docs-logo.astro";
import ToggleNav from "./toggle-nav.astro";
import DarkModeToggle from "../dark-mode-toggle.astro";
import ButtonLink from "../ui/button-link.astro";
import AlgoliaSearch from "./algolia-search.jsx";
import Logo from "@/components/ui/logo.astro";
import { DiscordIcon, GithubIcon, TwitterIcon } from "../header/icons";
const { nav } = Astro.props;
Expand All @@ -23,7 +24,8 @@ const pathname = new URL(Astro.request.url).pathname;
</a>
</div>
<div>
<div id="docsearch"></div>
<!-- <div id="docsearch"></div> -->
<AlgoliaSearch client:only />
</div>
</div>
<div class="hidden flex-shrink-0 md:flex md:gap-x-[14px]">
Expand Down Expand Up @@ -67,7 +69,7 @@ const pathname = new URL(Astro.request.url).pathname;
<!-- <ToggleNav nav={nav} /> -->
</nav>

<script>
<!-- <script >
import docsearch from "@docsearch/js";
import "@docsearch/css";
Expand All @@ -78,4 +80,4 @@ const pathname = new URL(Astro.request.url).pathname;
apiKey: "ab27356463ffa13e3d75727cd71bfc69",
indexName: "akash",
});
</script>
</script> -->
28 changes: 20 additions & 8 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
/* .ec-theme-dark-plus {
display: none !important;
} */
--docsearch-primary-color: #ff414c;
--docsearch-searchbox-focus-background: hsl(0 0% 100%);
--docsearch-modal-background: hsl(0 0% 100%);
--docsearch-primary-color: #ff414c !important;
--docsearch-searchbox-focus-background: hsl(0 0% 100%) !important;
--docsearch-modal-background: hsl(0 0% 100%) !important;
}

.dark {
Expand All @@ -76,8 +76,20 @@
--three-dots-bg: #515151;
--default-border: 0 0% 18%;

--docsearch-searchbox-focus-background: hsl(0 0% 14%);
--docsearch-modal-background: hsl(0 0% 14%);
--docsearch-searchbox-focus-background: hsl(0 0% 14%) !important;
--docsearch-modal-background: hsl(0 0% 14%) !important;
--docsearch-modal-shadow: inset 1px 1px 0 0 hsla(0, 0%, 26%, 0.5),
0 3px 8px 0 #555a64 !important;
--docsearch-key-gradient: linear-gradient(
-225deg,
#252525,
#202020
) !important;
--docsearch-key-shadow: inset 0 -2px 0 0 #383838, inset 0 0 1px 1px #4d4d4d,
0 1px 2px 1px rgba(30, 35, 90, 0.4) !important;
--docsearch-footer-background: hsl(0 0% 11%) !important;
--docsearch-footer-shadow: 0 -1px 0 0 #181818 0 -3px 6px 0
rgba(69, 98, 155, 0.12) !important;
}
}

Expand Down Expand Up @@ -222,8 +234,8 @@
/* doc-search */

.DocSearch-Button {
border: 1px solid hsl(var(--default-border));
border-radius: 4px;
border: 1px solid hsl(var(--default-border)) !important;
border-radius: 4px !important;
height: 38px;
/* background-color: hsl(var(--background2)); */
width: 22rem;
Expand All @@ -241,5 +253,5 @@
}

.DocSearch-Button-Placeholder {
color: hsl(var(--para));
color: hsl(var(--para)) !important;
}

0 comments on commit 8a41430

Please sign in to comment.