Files
Hayden Bleasel cf9ccd0076 Open Source Docs (#272)
* Scaffold Geistdocs instance

* Update biome.json

* Replace content

* Re-path docs

* Update docs package name

* Misc fixes

* Update geistdocs.tsx

* Move content to correct folder

* Start migrating custom components

* Finish migrating custom components

* Migrate existing redirects

* Remove #next suffixes from code blocks

* Migrate homepage and flags

* Remove duplicate lockfiles

* Start fixing homepage

* Replace Geist components

* Fix colors

* Improve layout

* Fix code blocks

* Fix hero

* Fix illustrations

* Fix redirect

* Fix nav links

* Patch in FrameworkSwitcher

* Bump Next.js in docs

* Delete turbo.json

* Misc fixes

* More logo fixes
2026-02-13 09:06:03 +02:00

79 lines
1.9 KiB
TypeScript

"use client";
import { useDocsSearch } from "fumadocs-core/search/client";
import {
SearchDialog as FumadocsSearchDialog,
SearchDialogClose,
SearchDialogContent,
SearchDialogHeader,
SearchDialogIcon,
SearchDialogInput,
SearchDialogList,
SearchDialogOverlay,
type SharedProps,
} from "fumadocs-ui/components/dialog/search";
import { useI18n } from "fumadocs-ui/contexts/i18n";
import { useSearchContext } from "fumadocs-ui/contexts/search";
import { cn } from "@/lib/utils";
import { Button } from "../ui/button";
import { Kbd } from "../ui/kbd";
type SearchButtonProps = {
className?: string;
onClick?: () => void;
};
export const SearchDialog = ({
basePath,
...props
}: SharedProps & { basePath: string | undefined }) => {
const { locale } = useI18n();
const { search, setSearch, query } = useDocsSearch({
type: "fetch",
locale,
api: basePath ? `${basePath}/api/search` : "/api/search",
});
return (
<FumadocsSearchDialog
isLoading={query.isLoading}
onSearchChange={setSearch}
search={search}
{...props}
>
<SearchDialogOverlay />
<SearchDialogContent>
<SearchDialogHeader>
<SearchDialogIcon />
<SearchDialogInput />
<SearchDialogClose />
</SearchDialogHeader>
<SearchDialogList items={query.data !== "empty" ? query.data : null} />
</SearchDialogContent>
</FumadocsSearchDialog>
);
};
export const SearchButton = ({ className, onClick }: SearchButtonProps) => {
const { setOpenSearch } = useSearchContext();
return (
<Button
className={cn(
"justify-between gap-8 pr-1.5 font-normal text-muted-foreground shadow-none",
className
)}
onClick={() => {
setOpenSearch(true);
onClick?.();
}}
size="sm"
type="button"
variant="outline"
>
<span>Search...</span>
<Kbd className="border bg-background font-medium">K</Kbd>
</Button>
);
};