mirror of
https://github.com/vercel/flags.git
synced 2026-09-19 03:49:23 +08:00
cf9ccd0076
* 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
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
"use client";
|
|
|
|
import { Analytics } from "@vercel/analytics/next";
|
|
import { SpeedInsights } from "@vercel/speed-insights/next";
|
|
import type { SharedProps } from "fumadocs-ui/contexts/search";
|
|
import { RootProvider } from "fumadocs-ui/provider/next";
|
|
import { type ComponentProps, useCallback } from "react";
|
|
import { Toaster } from "@/components/ui/sonner";
|
|
import { useChatContext } from "@/hooks/geistdocs/use-chat";
|
|
import { useIsMobile } from "@/hooks/use-mobile";
|
|
import { i18n, i18nProvider } from "@/lib/geistdocs/i18n";
|
|
import { cn } from "@/lib/utils";
|
|
import { TooltipProvider } from "../ui/tooltip";
|
|
import { SearchDialog } from "./search";
|
|
|
|
type GeistdocsProviderProps = ComponentProps<typeof RootProvider> & {
|
|
basePath: string | undefined;
|
|
className?: string;
|
|
lang?: string;
|
|
};
|
|
|
|
export const GeistdocsProvider = ({
|
|
basePath,
|
|
search,
|
|
className,
|
|
lang = i18n.defaultLanguage,
|
|
...props
|
|
}: GeistdocsProviderProps) => {
|
|
const { isOpen } = useChatContext();
|
|
const isMobile = useIsMobile();
|
|
const isSidebarVisible = isOpen && !isMobile;
|
|
|
|
const SearchDialogComponent = useCallback(
|
|
(sdProps: SharedProps) => <SearchDialog basePath={basePath} {...sdProps} />,
|
|
[basePath]
|
|
);
|
|
|
|
return (
|
|
<div
|
|
className={cn(
|
|
"transition-all",
|
|
isSidebarVisible ? "pr-96!" : null,
|
|
className
|
|
)}
|
|
>
|
|
<TooltipProvider>
|
|
<RootProvider
|
|
i18n={i18nProvider(lang)}
|
|
search={{
|
|
SearchDialog: SearchDialogComponent,
|
|
...search,
|
|
}}
|
|
{...props}
|
|
/>
|
|
</TooltipProvider>
|
|
<Analytics />
|
|
<Toaster />
|
|
<SpeedInsights />
|
|
</div>
|
|
);
|
|
};
|