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

feat(site): add orama search #1948

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@mdx-js/react": "^2.1.5",
"@next/mdx": "^14.0.1",
"@next/third-parties": "latest",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: using 'latest' tag can lead to unexpected breaking changes in production. Consider pinning to a specific version

"@orama/react-components": "^0.3.2",
"@rivet-gg/api": "^0.0.1-rc19",
"@rivet-gg/components": "workspace:*",
"@rivet-gg/icons": "workspace:*",
Expand Down
2 changes: 2 additions & 0 deletions site/src/components/v2/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Image from "next/image";
import Link from "next/link";
import { type ReactNode, useState } from "react";
import { HeaderPopupProductMenu } from "../HeaderPopupProductMenu";
import { HeaderSearch } from "./HeaderSearch";

interface HeaderProps {
active: "product" | "docs" | "blog" | "pricing" | "solutions";
Expand Down Expand Up @@ -49,6 +50,7 @@ export function Header({ active, subnav }: HeaderProps) {
}
links={
<>
<HeaderSearch />
<RivetHeader.NavItem asChild className="-m-2 p-2">
<Link href="/discord">
<Icon icon={faDiscord} />
Expand Down
47 changes: 47 additions & 0 deletions site/src/components/v2/HeaderSearch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"use client";
import { OramaSearchBox } from "@orama/react-components";
import { Button, Dialog, DialogPortal, Kbd, cn } from "@rivet-gg/components";
import { useState } from "react";

export function HeaderSearch() {
const [isOpen, setIsOpen] = useState(false);
return (
<>
<Button
onClick={() => setIsOpen(true)}
variant="outline"
className={cn(
"relative h-8 w-full justify-start rounded-[0.5rem] bg-background text-sm font-normal text-muted-foreground shadow-none hidden md:flex md:w-24 lg:w-40",
)}
>
<span className="hidden lg:inline-flex">Search...</span>
<span className="inline-flex lg:hidden">Search...</span>
<Kbd className="absolute right-[0.3rem] top-[0.3rem] hidden sm:flex">
<Kbd.Cmd />K
</Kbd>
Comment on lines +19 to +21
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Keyboard shortcut (Cmd+K) is displayed but no keyboard event handler is implemented to handle this shortcut

</Button>
<Dialog open={isOpen}>
<DialogPortal>
<OramaSearchBox
open={isOpen}
layout="modal"
onModalStatusChanged={(status) => setIsOpen(!status)}
colorScheme="system"
onSearchResultClick={() => setIsOpen(false)}
placeholder="Search something..."
index={{
endpoint:
"https://cloud.orama.run/v1/indexes/rivet-gg-b87fiw",
api_key: "dcVm1fAKZeTdOfGFZCCH9xWiH7JeYCQZ",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: API key should not be hardcoded in the source code. Move this to an environment variable.

}}
resultMap={{
title: "name",
description: "content",
section: "category",
}}
/>
</DialogPortal>
</Dialog>
</>
);
}
Loading
Loading