@vercel/geistdocs 1.2.3 → 1.3.0-canary.41d37f1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +3 -0
- package/dist/components/callout.d.ts +12 -0
- package/dist/components/callout.d.ts.map +1 -0
- package/dist/components/callout.js +7 -0
- package/dist/components/code-block-tabs.d.ts +7 -0
- package/dist/components/code-block-tabs.d.ts.map +1 -0
- package/dist/components/code-block-tabs.js +7 -0
- package/dist/components/code-block.d.ts +14 -0
- package/dist/components/code-block.d.ts.map +1 -0
- package/dist/components/code-block.js +41 -0
- package/dist/components/mermaid.d.ts +4 -0
- package/dist/components/mermaid.d.ts.map +1 -0
- package/dist/components/mermaid.js +44 -0
- package/dist/components/theme-aware-image.d.ts +12 -0
- package/dist/components/theme-aware-image.d.ts.map +1 -0
- package/dist/components/theme-aware-image.js +8 -0
- package/dist/components/video.d.ts +6 -0
- package/dist/components/video.d.ts.map +1 -0
- package/dist/components/video.js +3 -0
- package/dist/config.d.ts +52 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +1 -0
- package/dist/controls.d.ts +15 -0
- package/dist/controls.d.ts.map +1 -0
- package/dist/controls.js +52 -0
- package/dist/internal/chat/context.d.ts +19 -0
- package/dist/internal/chat/context.d.ts.map +1 -0
- package/dist/internal/chat/context.js +36 -0
- package/dist/internal/chat/conversation.d.ts +10 -0
- package/dist/internal/chat/conversation.d.ts.map +1 -0
- package/dist/internal/chat/conversation.js +16 -0
- package/dist/internal/chat/copy-chat.d.ts +5 -0
- package/dist/internal/chat/copy-chat.d.ts.map +1 -0
- package/dist/internal/chat/copy-chat.js +35 -0
- package/dist/internal/chat/db.d.ts +13 -0
- package/dist/internal/chat/db.d.ts.map +1 -0
- package/dist/internal/chat/db.js +19 -0
- package/dist/internal/chat/message-metadata.d.ts +8 -0
- package/dist/internal/chat/message-metadata.d.ts.map +1 -0
- package/dist/internal/chat/message-metadata.js +29 -0
- package/dist/internal/chat/message.d.ts +11 -0
- package/dist/internal/chat/message.d.ts.map +1 -0
- package/dist/internal/chat/message.js +11 -0
- package/dist/internal/chat/prompt-input.d.ts +13 -0
- package/dist/internal/chat/prompt-input.d.ts.map +1 -0
- package/dist/internal/chat/prompt-input.js +39 -0
- package/dist/internal/chat/shell.d.ts +2 -0
- package/dist/internal/chat/shell.d.ts.map +1 -0
- package/dist/internal/chat/shell.js +194 -0
- package/dist/internal/chat/shimmer.d.ts +11 -0
- package/dist/internal/chat/shimmer.d.ts.map +1 -0
- package/dist/internal/chat/shimmer.js +18 -0
- package/dist/internal/chat/sources.d.ts +13 -0
- package/dist/internal/chat/sources.d.ts.map +1 -0
- package/dist/internal/chat/sources.js +9 -0
- package/dist/internal/chat/suggestion.d.ts +11 -0
- package/dist/internal/chat/suggestion.d.ts.map +1 -0
- package/dist/internal/chat/suggestion.js +12 -0
- package/dist/internal/cn.d.ts +3 -0
- package/dist/internal/cn.d.ts.map +1 -0
- package/dist/internal/cn.js +3 -0
- package/dist/internal/feedback-action.d.ts +14 -0
- package/dist/internal/feedback-action.d.ts.map +1 -0
- package/dist/internal/feedback-action.js +34 -0
- package/dist/internal/i18n.d.ts +6 -0
- package/dist/internal/i18n.d.ts.map +1 -0
- package/dist/internal/i18n.js +18 -0
- package/dist/internal/languages.d.ts +7 -0
- package/dist/internal/languages.d.ts.map +1 -0
- package/dist/internal/languages.js +18 -0
- package/dist/internal/not-implemented.d.ts +2 -0
- package/dist/internal/not-implemented.d.ts.map +1 -0
- package/dist/internal/not-implemented.js +4 -0
- package/dist/internal/page-actions-client.d.ts +14 -0
- package/dist/internal/page-actions-client.d.ts.map +1 -0
- package/dist/internal/page-actions-client.js +154 -0
- package/dist/internal/page-actions.d.ts +18 -0
- package/dist/internal/page-actions.d.ts.map +1 -0
- package/dist/internal/page-actions.js +4 -0
- package/dist/internal/search.d.ts +5 -0
- package/dist/internal/search.d.ts.map +1 -0
- package/dist/internal/search.js +14 -0
- package/dist/internal/sidebar.d.ts +6 -0
- package/dist/internal/sidebar.d.ts.map +1 -0
- package/dist/internal/sidebar.js +37 -0
- package/dist/internal/ui/button-group.d.ts +13 -0
- package/dist/internal/ui/button-group.d.ts.map +1 -0
- package/dist/internal/ui/button-group.js +26 -0
- package/dist/internal/ui/button.d.ts +12 -0
- package/dist/internal/ui/button.d.ts.map +1 -0
- package/dist/internal/ui/button.js +33 -0
- package/dist/internal/ui/card.d.ts +6 -0
- package/dist/internal/ui/card.d.ts.map +1 -0
- package/dist/internal/ui/card.js +14 -0
- package/dist/internal/ui/collapsible.d.ts +6 -0
- package/dist/internal/ui/collapsible.d.ts.map +1 -0
- package/dist/internal/ui/collapsible.js +12 -0
- package/dist/internal/ui/drawer.d.ts +6 -0
- package/dist/internal/ui/drawer.d.ts.map +1 -0
- package/dist/internal/ui/drawer.js +13 -0
- package/dist/internal/ui/dropdown-menu.d.ts +22 -0
- package/dist/internal/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/internal/ui/dropdown-menu.js +41 -0
- package/dist/internal/ui/input-group.d.ts +15 -0
- package/dist/internal/ui/input-group.d.ts.map +1 -0
- package/dist/internal/ui/input-group.js +44 -0
- package/dist/internal/ui/input.d.ts +3 -0
- package/dist/internal/ui/input.d.ts.map +1 -0
- package/dist/internal/ui/input.js +5 -0
- package/dist/internal/ui/kbd.d.ts +4 -0
- package/dist/internal/ui/kbd.d.ts.map +1 -0
- package/dist/internal/ui/kbd.js +8 -0
- package/dist/internal/ui/popover.d.ts +6 -0
- package/dist/internal/ui/popover.d.ts.map +1 -0
- package/dist/internal/ui/popover.js +13 -0
- package/dist/internal/ui/scroll-area.d.ts +5 -0
- package/dist/internal/ui/scroll-area.d.ts.map +1 -0
- package/dist/internal/ui/scroll-area.js +12 -0
- package/dist/internal/ui/separator.d.ts +4 -0
- package/dist/internal/ui/separator.d.ts.map +1 -0
- package/dist/internal/ui/separator.js +7 -0
- package/dist/internal/ui/sheet.d.ts +10 -0
- package/dist/internal/ui/sheet.d.ts.map +1 -0
- package/dist/internal/ui/sheet.js +24 -0
- package/dist/internal/ui/sonner.d.ts +3 -0
- package/dist/internal/ui/sonner.d.ts.map +1 -0
- package/dist/internal/ui/sonner.js +20 -0
- package/dist/internal/ui/spinner.d.ts +3 -0
- package/dist/internal/ui/spinner.d.ts.map +1 -0
- package/dist/internal/ui/spinner.js +6 -0
- package/dist/internal/ui/textarea.d.ts +3 -0
- package/dist/internal/ui/textarea.d.ts.map +1 -0
- package/dist/internal/ui/textarea.js +5 -0
- package/dist/internal/ui/tooltip.d.ts +7 -0
- package/dist/internal/ui/tooltip.d.ts.map +1 -0
- package/dist/internal/ui/tooltip.js +16 -0
- package/dist/internal/use-mobile.d.ts +2 -0
- package/dist/internal/use-mobile.d.ts.map +1 -0
- package/dist/internal/use-mobile.js +16 -0
- package/dist/layout.d.ts +18 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +49 -0
- package/dist/mdx.d.ts +36 -0
- package/dist/mdx.d.ts.map +1 -0
- package/dist/mdx.js +72 -0
- package/dist/pages/docs.d.ts +55 -0
- package/dist/pages/docs.d.ts.map +1 -0
- package/dist/pages/docs.js +63 -0
- package/dist/proxy.d.ts +21 -0
- package/dist/proxy.d.ts.map +1 -0
- package/dist/proxy.js +109 -0
- package/dist/routes/chat.d.ts +13 -0
- package/dist/routes/chat.d.ts.map +1 -0
- package/dist/routes/chat.js +229 -0
- package/dist/routes/llms.d.ts +33 -0
- package/dist/routes/llms.d.ts.map +1 -0
- package/dist/routes/llms.js +39 -0
- package/dist/routes/search.d.ts +10 -0
- package/dist/routes/search.d.ts.map +1 -0
- package/dist/routes/search.js +33 -0
- package/dist/routes/sitemap.d.ts +35 -0
- package/dist/routes/sitemap.d.ts.map +1 -0
- package/dist/routes/sitemap.js +150 -0
- package/dist/source.d.ts +30 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +72 -0
- package/package.json +129 -9
- package/styles.css +193 -0
- package/template/_gitignore +1 -0
- package/template/app/[lang]/(home)/components/centered-section.tsx +26 -0
- package/template/app/[lang]/(home)/components/cta.tsx +19 -0
- package/template/app/[lang]/(home)/components/hero.tsx +27 -0
- package/template/app/[lang]/(home)/components/one-two-section.tsx +25 -0
- package/template/app/[lang]/(home)/components/templates.tsx +50 -0
- package/template/app/[lang]/(home)/components/text-grid-section.tsx +20 -0
- package/template/app/[lang]/(home)/layout.tsx +14 -0
- package/template/app/[lang]/(home)/page.tsx +126 -0
- package/template/app/[lang]/docs/[[...slug]]/page.tsx +19 -0
- package/template/app/[lang]/docs/layout.tsx +14 -0
- package/template/app/[lang]/layout.tsx +29 -0
- package/template/app/[lang]/llms.mdx/[[...slug]]/route.ts +7 -0
- package/template/app/[lang]/llms.txt/route.ts +6 -0
- package/template/app/[lang]/og/[...slug]/background.png +0 -0
- package/template/app/[lang]/og/[...slug]/geist-sans-regular.ttf +0 -0
- package/template/app/[lang]/og/[...slug]/geist-sans-semibold.ttf +0 -0
- package/template/app/[lang]/og/[...slug]/route.tsx +95 -0
- package/template/app/[lang]/rss.xml/route.ts +52 -0
- package/template/app/[lang]/sitemap.md/route.ts +9 -0
- package/template/app/actions/feedback/emotions.ts +18 -0
- package/template/app/actions/feedback/index.ts +45 -0
- package/template/app/api/chat/route.ts +8 -0
- package/template/app/api/search/route.ts +5 -0
- package/template/app/favicon.ico +0 -0
- package/template/app/global.css +2 -0
- package/template/app/robots.ts +14 -0
- package/template/app/sitemap.ts +36 -0
- package/template/app/styles/geistdocs.css +553 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-arrow-up-right-small.tsx +35 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-arrow-up-right.tsx +27 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-check.tsx +27 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-chevron-down-small.tsx +30 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-chevron-right.tsx +27 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-copy.tsx +27 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-file-text.tsx +25 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-menu-alt.tsx +27 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-slash-forward.tsx +36 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/index.tsx +11 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/index.tsx +14 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-ai-elements.tsx +29 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-ai-sdk.tsx +38 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-chat-sdk.tsx +42 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-flags-sdk.tsx +42 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-icon-vercel.tsx +31 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-streamdown.tsx +29 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-vercel-oss.tsx +24 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-workflow-sdk.tsx +73 -0
- package/template/components/geistdocs/callout.tsx +40 -0
- package/template/components/geistdocs/chat.tsx +24 -0
- package/template/components/geistdocs/code-block-tabs.tsx +61 -0
- package/template/components/geistdocs/code-block.tsx +134 -0
- package/template/components/geistdocs/copy-page.tsx +27 -0
- package/template/components/geistdocs/desktop-menu.tsx +52 -0
- package/template/components/geistdocs/docs-layout.tsx +20 -0
- package/template/components/geistdocs/docs-page.tsx +35 -0
- package/template/components/geistdocs/edit-source.tsx +30 -0
- package/template/components/geistdocs/feedback.tsx +139 -0
- package/template/components/geistdocs/footer.tsx +30 -0
- package/template/components/geistdocs/github-button.tsx +19 -0
- package/template/components/geistdocs/home-layout.tsx +46 -0
- package/template/components/geistdocs/icons.tsx +13 -0
- package/template/components/geistdocs/installer.tsx +58 -0
- package/template/components/geistdocs/language-selector.tsx +3 -0
- package/template/components/geistdocs/mdx-components.tsx +5 -0
- package/template/components/geistdocs/mermaid.tsx +68 -0
- package/template/components/geistdocs/mobile-docs-bar.tsx +81 -0
- package/template/components/geistdocs/mobile-menu.tsx +150 -0
- package/template/components/geistdocs/navbar-logo.tsx +124 -0
- package/template/components/geistdocs/navbar.tsx +22 -0
- package/template/components/geistdocs/provider.tsx +31 -0
- package/template/components/geistdocs/rss-button.tsx +10 -0
- package/template/components/geistdocs/scroll-top.tsx +21 -0
- package/template/components/geistdocs/search.tsx +17 -0
- package/template/components/geistdocs/sidebar.tsx +128 -0
- package/template/components/geistdocs/theme-aware-image.tsx +22 -0
- package/template/components/geistdocs/theme-toggle.tsx +3 -0
- package/template/components/geistdocs/video.tsx +16 -0
- package/template/components/ui/badge.tsx +46 -0
- package/template/components/ui/button-group.tsx +83 -0
- package/template/components/ui/button.tsx +60 -0
- package/template/components/ui/card.tsx +92 -0
- package/template/components/ui/collapsible.tsx +33 -0
- package/template/components/ui/command-prompt.tsx +488 -0
- package/template/components/ui/command.tsx +184 -0
- package/template/components/ui/dialog.tsx +143 -0
- package/template/components/ui/drawer.tsx +135 -0
- package/template/components/ui/dropdown-menu.tsx +257 -0
- package/template/components/ui/hover-card.tsx +44 -0
- package/template/components/ui/input-group.tsx +170 -0
- package/template/components/ui/input.tsx +21 -0
- package/template/components/ui/kbd.tsx +28 -0
- package/template/components/ui/navigation-menu.tsx +192 -0
- package/template/components/ui/popover.tsx +48 -0
- package/template/components/ui/scroll-area.tsx +58 -0
- package/template/components/ui/select.tsx +187 -0
- package/template/components/ui/separator.tsx +28 -0
- package/template/components/ui/sheet.tsx +139 -0
- package/template/components/ui/sonner.tsx +40 -0
- package/template/components/ui/spinner.tsx +16 -0
- package/template/components/ui/textarea.tsx +18 -0
- package/template/components/ui/tooltip.tsx +61 -0
- package/template/components.json +22 -0
- package/template/content/docs/ask-ai.cn.mdx +85 -0
- package/template/content/docs/ask-ai.mdx +85 -0
- package/template/content/docs/configuration.cn.mdx +115 -0
- package/template/content/docs/configuration.mdx +115 -0
- package/template/content/docs/deployment.cn.mdx +34 -0
- package/template/content/docs/deployment.mdx +34 -0
- package/template/content/docs/edit-on-github.cn.mdx +47 -0
- package/template/content/docs/edit-on-github.mdx +47 -0
- package/template/content/docs/env.cn.mdx +25 -0
- package/template/content/docs/env.mdx +25 -0
- package/template/content/docs/feedback.cn.mdx +85 -0
- package/template/content/docs/feedback.mdx +85 -0
- package/template/content/docs/getting-started.cn.mdx +86 -0
- package/template/content/docs/getting-started.mdx +86 -0
- package/template/content/docs/index.cn.mdx +54 -0
- package/template/content/docs/index.mdx +87 -0
- package/template/content/docs/internationalization.cn.mdx +113 -0
- package/template/content/docs/internationalization.mdx +117 -0
- package/template/content/docs/llms-txt.cn.mdx +50 -0
- package/template/content/docs/llms-txt.mdx +50 -0
- package/template/content/docs/md.cn.mdx +68 -0
- package/template/content/docs/md.mdx +68 -0
- package/template/content/docs/meta.json +21 -0
- package/template/content/docs/open-in-chat.cn.mdx +78 -0
- package/template/content/docs/open-in-chat.mdx +78 -0
- package/template/content/docs/provider.cn.mdx +69 -0
- package/template/content/docs/provider.mdx +69 -0
- package/template/content/docs/rss.cn.mdx +104 -0
- package/template/content/docs/rss.mdx +104 -0
- package/template/content/docs/syntax.cn.mdx +416 -0
- package/template/content/docs/syntax.mdx +407 -0
- package/template/content/docs/theme-aware-image.mdx +53 -0
- package/template/geistdocs.tsx +51 -0
- package/template/hooks/geistdocs/use-sidebar.ts +13 -0
- package/template/hooks/use-mobile.ts +19 -0
- package/template/lib/geistdocs/config.tsx +27 -0
- package/template/lib/geistdocs/fonts.ts +18 -0
- package/template/lib/geistdocs/i18n.ts +13 -0
- package/template/lib/geistdocs/md-tracking.ts +56 -0
- package/template/lib/geistdocs/source.ts +12 -0
- package/template/lib/utils.ts +6 -0
- package/template/next.config.ts +22 -0
- package/template/package.json +63 -0
- package/template/postcss.config.mjs +5 -0
- package/template/proxy.ts +16 -0
- package/template/source.config.ts +62 -0
- package/template/tsconfig.json +37 -0
- package/dist/index.js +0 -2
- /package/dist/{index.d.ts → cli/index.d.ts} +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
4
|
+
import {
|
|
5
|
+
type CSSProperties,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
useCallback,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
} from "react";
|
|
11
|
+
import { toast } from "sonner";
|
|
12
|
+
import { Button } from "@/components/ui/button";
|
|
13
|
+
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
14
|
+
import { cn } from "@/lib/utils";
|
|
15
|
+
|
|
16
|
+
interface CodeBlockProps {
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
"data-line-highlighting"?: string;
|
|
20
|
+
"data-line-numbers"?: string;
|
|
21
|
+
icon?: ReactNode;
|
|
22
|
+
style?: CSSProperties;
|
|
23
|
+
tabIndex?: number;
|
|
24
|
+
title?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const CodeBlock = ({
|
|
28
|
+
children,
|
|
29
|
+
className,
|
|
30
|
+
icon,
|
|
31
|
+
style,
|
|
32
|
+
tabIndex,
|
|
33
|
+
title,
|
|
34
|
+
...rest
|
|
35
|
+
}: CodeBlockProps) => {
|
|
36
|
+
const ref = useRef<HTMLPreElement>(null);
|
|
37
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
38
|
+
const { "data-line-numbers": lineNumbers } = rest;
|
|
39
|
+
|
|
40
|
+
const copyToClipboard = useCallback(async () => {
|
|
41
|
+
if (typeof window === "undefined" || !navigator?.clipboard?.writeText) {
|
|
42
|
+
toast.error("Clipboard API not available");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const code = ref.current?.innerText;
|
|
47
|
+
|
|
48
|
+
if (!code) {
|
|
49
|
+
toast.error("No code to copy");
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
await navigator.clipboard.writeText(code);
|
|
55
|
+
setIsCopied(true);
|
|
56
|
+
setTimeout(() => setIsCopied(false), 2000);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
59
|
+
|
|
60
|
+
toast.error(message);
|
|
61
|
+
}
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
64
|
+
const Icon = isCopied ? CheckIcon : CopyIcon;
|
|
65
|
+
|
|
66
|
+
const CodeBlockComponent = useCallback(
|
|
67
|
+
(props: { className?: string }) => (
|
|
68
|
+
<pre
|
|
69
|
+
className={cn(
|
|
70
|
+
"not-prose flex-1 overflow-x-auto rounded-sm border bg-background py-3 text-sm outline-none",
|
|
71
|
+
"[&>code]:grid [&>code]:min-w-max",
|
|
72
|
+
className,
|
|
73
|
+
props.className
|
|
74
|
+
)}
|
|
75
|
+
ref={ref}
|
|
76
|
+
style={style}
|
|
77
|
+
tabIndex={tabIndex}
|
|
78
|
+
>
|
|
79
|
+
{children}
|
|
80
|
+
</pre>
|
|
81
|
+
),
|
|
82
|
+
[children, style, tabIndex, className]
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
if (!title) {
|
|
86
|
+
return (
|
|
87
|
+
<div className="relative mb-6">
|
|
88
|
+
<CodeBlockComponent
|
|
89
|
+
className={cn(lineNumbers ? "line-numbers" : "", className)}
|
|
90
|
+
/>
|
|
91
|
+
<Button
|
|
92
|
+
className="absolute top-[5px] right-[5px] bg-background/80 backdrop-blur-sm"
|
|
93
|
+
onClick={copyToClipboard}
|
|
94
|
+
size="icon"
|
|
95
|
+
variant="ghost"
|
|
96
|
+
>
|
|
97
|
+
<Icon size={14} />
|
|
98
|
+
</Button>
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<Card className="not-prose mb-6 gap-0 overflow-hidden rounded-sm p-0 shadow-none">
|
|
105
|
+
<CardHeader className="flex items-center gap-2 border-b bg-sidebar py-1.5! pr-1.5 pl-4 text-muted-foreground">
|
|
106
|
+
<div
|
|
107
|
+
className="flex size-3.5 shrink-0"
|
|
108
|
+
// biome-ignore lint/security/noDangerouslySetInnerHtml: "Required for icon prop."
|
|
109
|
+
dangerouslySetInnerHTML={{ __html: icon as unknown as TrustedHTML }}
|
|
110
|
+
/>
|
|
111
|
+
<CardTitle className="flex-1 font-mono font-normal text-sm tracking-tight">
|
|
112
|
+
{title}
|
|
113
|
+
</CardTitle>
|
|
114
|
+
<Button
|
|
115
|
+
className={cn("shrink-0", className)}
|
|
116
|
+
onClick={copyToClipboard}
|
|
117
|
+
size="icon"
|
|
118
|
+
variant="ghost"
|
|
119
|
+
>
|
|
120
|
+
<Icon size={14} />
|
|
121
|
+
</Button>
|
|
122
|
+
</CardHeader>
|
|
123
|
+
<CardContent className="p-0">
|
|
124
|
+
<CodeBlockComponent
|
|
125
|
+
className={cn(
|
|
126
|
+
className,
|
|
127
|
+
"rounded-none border-none",
|
|
128
|
+
lineNumbers ? "line-numbers" : ""
|
|
129
|
+
)}
|
|
130
|
+
/>
|
|
131
|
+
</CardContent>
|
|
132
|
+
</Card>
|
|
133
|
+
);
|
|
134
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useCopyButton } from "fumadocs-ui/utils/use-copy-button";
|
|
4
|
+
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
5
|
+
|
|
6
|
+
interface CopyPageProps {
|
|
7
|
+
text: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const CopyPage = ({ text }: CopyPageProps) => {
|
|
11
|
+
const [checked, handleCopy] = useCopyButton(async () => {
|
|
12
|
+
await navigator.clipboard.writeText(text);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const Icon = checked ? CheckIcon : CopyIcon;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<button
|
|
19
|
+
className="flex items-center gap-1.5 text-muted-foreground text-sm transition-colors hover:text-foreground"
|
|
20
|
+
onClick={handleCopy}
|
|
21
|
+
type="button"
|
|
22
|
+
>
|
|
23
|
+
<Icon className="size-3.5" />
|
|
24
|
+
<span>Copy page</span>
|
|
25
|
+
</button>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import DynamicLink from "fumadocs-core/dynamic-link";
|
|
4
|
+
import { IconArrowUpRightSmall } from "@/components/geistcn-fallbacks/geistcn-assets/icons/icon-arrow-up-right-small";
|
|
5
|
+
import {
|
|
6
|
+
NavigationMenu,
|
|
7
|
+
NavigationMenuItem,
|
|
8
|
+
NavigationMenuLink,
|
|
9
|
+
NavigationMenuList,
|
|
10
|
+
} from "@/components/ui/navigation-menu";
|
|
11
|
+
import { useIsMobile } from "@/hooks/use-mobile";
|
|
12
|
+
import { cn } from "@/lib/utils";
|
|
13
|
+
|
|
14
|
+
interface DesktopMenuProps {
|
|
15
|
+
className?: string;
|
|
16
|
+
items: { label: string; href: string }[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const DesktopMenu = ({ items, className }: DesktopMenuProps) => {
|
|
20
|
+
const isMobile = useIsMobile();
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<NavigationMenu viewport={isMobile}>
|
|
24
|
+
<NavigationMenuList className={cn("h-14 gap-4", className)}>
|
|
25
|
+
{items.map((item) => (
|
|
26
|
+
<NavigationMenuItem key={item.href}>
|
|
27
|
+
<NavigationMenuLink
|
|
28
|
+
asChild
|
|
29
|
+
className="flex items-center text-gray-900 text-sm transition-colors duration-100 hover:text-gray-1000"
|
|
30
|
+
>
|
|
31
|
+
{item.href.startsWith("http") ? (
|
|
32
|
+
<a
|
|
33
|
+
className="flex flex-row items-center gap-1"
|
|
34
|
+
href={item.href}
|
|
35
|
+
rel="noopener"
|
|
36
|
+
target="_blank"
|
|
37
|
+
>
|
|
38
|
+
{item.label}
|
|
39
|
+
<IconArrowUpRightSmall aria-hidden="true" size={12} />
|
|
40
|
+
</a>
|
|
41
|
+
) : (
|
|
42
|
+
<DynamicLink href={`/[lang]${item.href}`}>
|
|
43
|
+
{item.label}
|
|
44
|
+
</DynamicLink>
|
|
45
|
+
)}
|
|
46
|
+
</NavigationMenuLink>
|
|
47
|
+
</NavigationMenuItem>
|
|
48
|
+
))}
|
|
49
|
+
</NavigationMenuList>
|
|
50
|
+
</NavigationMenu>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GeistdocsDocsLayout as PackageDocsLayout } from "@vercel/geistdocs/layout";
|
|
2
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
3
|
+
import { config } from "@/lib/geistdocs/config";
|
|
4
|
+
|
|
5
|
+
interface DocsLayoutProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
tree: ComponentProps<typeof PackageDocsLayout>["tree"];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const DocsLayout = ({ tree, children }: DocsLayoutProps) => (
|
|
11
|
+
<PackageDocsLayout
|
|
12
|
+
config={config}
|
|
13
|
+
containerProps={{
|
|
14
|
+
className: "mx-auto max-w-[1448px] bg-background-200",
|
|
15
|
+
}}
|
|
16
|
+
tree={tree}
|
|
17
|
+
>
|
|
18
|
+
{children}
|
|
19
|
+
</PackageDocsLayout>
|
|
20
|
+
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DocsBody as FumadocsDocsBody,
|
|
3
|
+
DocsDescription as FumadocsDocsDescription,
|
|
4
|
+
DocsPage as FumadocsDocsPage,
|
|
5
|
+
DocsTitle as FumadocsDocsTitle,
|
|
6
|
+
} from "fumadocs-ui/layouts/docs/page";
|
|
7
|
+
import type { ComponentProps } from "react";
|
|
8
|
+
import { cn } from "@/lib/utils";
|
|
9
|
+
|
|
10
|
+
type PageProps = ComponentProps<typeof FumadocsDocsPage>;
|
|
11
|
+
|
|
12
|
+
export const DocsPage = ({ ...props }: PageProps) => (
|
|
13
|
+
<FumadocsDocsPage {...props} />
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export const DocsTitle = ({
|
|
17
|
+
className,
|
|
18
|
+
...props
|
|
19
|
+
}: ComponentProps<typeof FumadocsDocsTitle>) => (
|
|
20
|
+
<FumadocsDocsTitle
|
|
21
|
+
className={cn("mb-4 text-4xl tracking-tight", className)}
|
|
22
|
+
{...props}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const DocsDescription = (
|
|
27
|
+
props: ComponentProps<typeof FumadocsDocsDescription>
|
|
28
|
+
) => <FumadocsDocsDescription {...props} />;
|
|
29
|
+
|
|
30
|
+
export const DocsBody = ({
|
|
31
|
+
className,
|
|
32
|
+
...props
|
|
33
|
+
}: ComponentProps<typeof FumadocsDocsBody>) => (
|
|
34
|
+
<FumadocsDocsBody className={cn("mx-auto w-full", className)} {...props} />
|
|
35
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SiGithub } from "@icons-pack/react-simple-icons";
|
|
2
|
+
import { github } from "@/geistdocs";
|
|
3
|
+
|
|
4
|
+
interface EditSourceProps {
|
|
5
|
+
path: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const EditSource = ({ path }: EditSourceProps) => {
|
|
9
|
+
let url: string | undefined;
|
|
10
|
+
|
|
11
|
+
if (github.owner && github.repo && path) {
|
|
12
|
+
url = `https://github.com/${github.owner}/${github.repo}/edit/main/content/docs/${path}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (!url) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<a
|
|
21
|
+
className="flex items-center gap-1.5 text-muted-foreground text-sm transition-colors hover:text-foreground"
|
|
22
|
+
href={url}
|
|
23
|
+
rel="noopener noreferrer"
|
|
24
|
+
target="_blank"
|
|
25
|
+
>
|
|
26
|
+
<SiGithub className="size-3.5" />
|
|
27
|
+
<span>Edit this page on GitHub</span>
|
|
28
|
+
</a>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { SiMarkdown } from "@icons-pack/react-simple-icons";
|
|
4
|
+
import { ThumbsUpIcon } from "lucide-react";
|
|
5
|
+
import { usePathname } from "next/navigation";
|
|
6
|
+
import {
|
|
7
|
+
type FormEventHandler,
|
|
8
|
+
useEffect,
|
|
9
|
+
useState,
|
|
10
|
+
useTransition,
|
|
11
|
+
} from "react";
|
|
12
|
+
import { sendFeedback } from "@/app/actions/feedback";
|
|
13
|
+
import { emotions } from "@/app/actions/feedback/emotions";
|
|
14
|
+
import { cn } from "@/lib/utils";
|
|
15
|
+
import { Button } from "../ui/button";
|
|
16
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";
|
|
17
|
+
import { Textarea } from "../ui/textarea";
|
|
18
|
+
|
|
19
|
+
type Emotion = (typeof emotions)[number]["name"];
|
|
20
|
+
|
|
21
|
+
export interface Feedback {
|
|
22
|
+
emotion: Emotion;
|
|
23
|
+
message: string;
|
|
24
|
+
url?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const Feedback = () => {
|
|
28
|
+
const url = usePathname();
|
|
29
|
+
const [submitted, setSubmitted] = useState(false);
|
|
30
|
+
const [emotion, setEmotion] = useState<Emotion | null>(null);
|
|
31
|
+
const [message, setMessage] = useState("");
|
|
32
|
+
const [isPending, startTransition] = useTransition();
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const item = localStorage.getItem(`docs-feedback-${url}`);
|
|
36
|
+
|
|
37
|
+
if (!item) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
setSubmitted(true);
|
|
42
|
+
}, [url]);
|
|
43
|
+
|
|
44
|
+
const submit: FormEventHandler<HTMLFormElement> = (e) => {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
|
|
47
|
+
if (!emotion) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
startTransition(() => {
|
|
52
|
+
const feedback: Feedback = {
|
|
53
|
+
emotion,
|
|
54
|
+
message,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
sendFeedback(url, feedback).then(() => {
|
|
58
|
+
setSubmitted(true);
|
|
59
|
+
setMessage("");
|
|
60
|
+
setEmotion(null);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
e?.preventDefault();
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<Popover>
|
|
69
|
+
<PopoverTrigger asChild>
|
|
70
|
+
<button
|
|
71
|
+
className="flex items-center gap-1.5 text-muted-foreground text-sm transition-colors hover:text-foreground"
|
|
72
|
+
type="button"
|
|
73
|
+
>
|
|
74
|
+
<ThumbsUpIcon className="size-3.5" />
|
|
75
|
+
<span>Give feedback</span>
|
|
76
|
+
</button>
|
|
77
|
+
</PopoverTrigger>
|
|
78
|
+
<PopoverContent className="overflow-hidden p-0">
|
|
79
|
+
<div className="overflow-visible">
|
|
80
|
+
{submitted ? (
|
|
81
|
+
<div className="flex flex-col items-center gap-3 rounded-xl bg-sidebar px-3 py-6 text-center text-sm">
|
|
82
|
+
<p>Thank you for your feedback!</p>
|
|
83
|
+
</div>
|
|
84
|
+
) : (
|
|
85
|
+
<form className="flex flex-col" onSubmit={submit}>
|
|
86
|
+
<div className="p-2">
|
|
87
|
+
<Textarea
|
|
88
|
+
autoFocus
|
|
89
|
+
className="max-h-48 min-h-24 shadow-none"
|
|
90
|
+
onChange={(e) => setMessage(e.target.value)}
|
|
91
|
+
onKeyDown={(e) => {
|
|
92
|
+
if (!e.shiftKey && e.key === "Enter") {
|
|
93
|
+
e.currentTarget.form?.requestSubmit();
|
|
94
|
+
}
|
|
95
|
+
}}
|
|
96
|
+
placeholder="Leave your feedback..."
|
|
97
|
+
required
|
|
98
|
+
value={message}
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
<div className="flex items-center justify-end gap-1 px-2 text-muted-foreground">
|
|
102
|
+
<SiMarkdown className="inline size-3" />
|
|
103
|
+
<p className="text-xs"> supported</p>
|
|
104
|
+
</div>
|
|
105
|
+
<div className="mt-2 flex items-center justify-between border-t bg-sidebar p-2">
|
|
106
|
+
<div className="flex items-center gap-px">
|
|
107
|
+
{emotions.map((e) => (
|
|
108
|
+
<Button
|
|
109
|
+
className={cn(
|
|
110
|
+
"text-muted-foreground hover:text-foreground",
|
|
111
|
+
emotion === e.name ? "bg-accent text-foreground" : ""
|
|
112
|
+
)}
|
|
113
|
+
key={e.name}
|
|
114
|
+
onClick={() => setEmotion(e.name)}
|
|
115
|
+
size="sm"
|
|
116
|
+
type="button"
|
|
117
|
+
variant="ghost"
|
|
118
|
+
>
|
|
119
|
+
{e.emoji}
|
|
120
|
+
<span className="sr-only">{e.name}</span>
|
|
121
|
+
</Button>
|
|
122
|
+
))}
|
|
123
|
+
</div>
|
|
124
|
+
<Button
|
|
125
|
+
disabled={isPending || !emotion || !message}
|
|
126
|
+
size="sm"
|
|
127
|
+
type="submit"
|
|
128
|
+
variant="default"
|
|
129
|
+
>
|
|
130
|
+
Send
|
|
131
|
+
</Button>
|
|
132
|
+
</div>
|
|
133
|
+
</form>
|
|
134
|
+
)}
|
|
135
|
+
</div>
|
|
136
|
+
</PopoverContent>
|
|
137
|
+
</Popover>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SiVercel } from "@icons-pack/react-simple-icons";
|
|
2
|
+
import { GitHubButton } from "./github-button";
|
|
3
|
+
import { LanguageSelector } from "./language-selector";
|
|
4
|
+
import { RSSButton } from "./rss-button";
|
|
5
|
+
import { ThemeToggle } from "./theme-toggle";
|
|
6
|
+
|
|
7
|
+
interface FooterProps {
|
|
8
|
+
copyright?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Footer = ({
|
|
12
|
+
copyright = `Copyright Vercel ${new Date().getFullYear()}. All rights reserved.`,
|
|
13
|
+
}: FooterProps) => (
|
|
14
|
+
<footer className="border-t px-4 py-5 md:px-6">
|
|
15
|
+
<div className="mx-auto flex max-w-[1448px] flex-col items-center justify-between gap-4 sm:flex-row">
|
|
16
|
+
<div className="flex items-center gap-2">
|
|
17
|
+
<SiVercel className="size-4 shrink-0" />
|
|
18
|
+
<p className="text-center text-muted-foreground text-sm sm:text-left">
|
|
19
|
+
{copyright}
|
|
20
|
+
</p>
|
|
21
|
+
</div>
|
|
22
|
+
<div className="flex items-center gap-2">
|
|
23
|
+
<LanguageSelector />
|
|
24
|
+
<RSSButton />
|
|
25
|
+
<GitHubButton />
|
|
26
|
+
<ThemeToggle />
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</footer>
|
|
30
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SiGithub } from "@icons-pack/react-simple-icons";
|
|
2
|
+
import { github } from "@/geistdocs";
|
|
3
|
+
import { Button } from "../ui/button";
|
|
4
|
+
|
|
5
|
+
export const GitHubButton = () => {
|
|
6
|
+
if (!(github.owner && github.repo)) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const url = `https://github.com/${github.owner}/${github.repo}`;
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Button asChild size="icon-sm" type="button" variant="ghost">
|
|
14
|
+
<a href={url} rel="noopener" target="_blank">
|
|
15
|
+
<SiGithub className="size-4" />
|
|
16
|
+
</a>
|
|
17
|
+
</Button>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DocsLayout as FumadocsDocsLayout } from "fumadocs-ui/layouts/docs";
|
|
2
|
+
import type { ComponentProps, CSSProperties, ReactNode } from "react";
|
|
3
|
+
import { i18n } from "@/lib/geistdocs/i18n";
|
|
4
|
+
import { Folder, Item, Separator, Sidebar } from "./sidebar";
|
|
5
|
+
|
|
6
|
+
interface HomeLayoutProps {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
tree: ComponentProps<typeof FumadocsDocsLayout>["tree"];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const HomeLayout = ({ tree, children }: HomeLayoutProps) => (
|
|
12
|
+
<FumadocsDocsLayout
|
|
13
|
+
containerProps={{
|
|
14
|
+
className: "p-0! max-w-full mx-0 [&_[data-sidebar-placeholder]]:hidden",
|
|
15
|
+
style: {
|
|
16
|
+
display: "flex",
|
|
17
|
+
flexDirection: "column",
|
|
18
|
+
"--fd-docs-row-1": "4rem",
|
|
19
|
+
} as CSSProperties,
|
|
20
|
+
}}
|
|
21
|
+
i18n={i18n}
|
|
22
|
+
nav={{
|
|
23
|
+
enabled: false,
|
|
24
|
+
}}
|
|
25
|
+
searchToggle={{
|
|
26
|
+
enabled: false,
|
|
27
|
+
}}
|
|
28
|
+
sidebar={{
|
|
29
|
+
className: "md:hidden",
|
|
30
|
+
collapsible: false,
|
|
31
|
+
component: <Sidebar />,
|
|
32
|
+
components: {
|
|
33
|
+
Folder,
|
|
34
|
+
Item,
|
|
35
|
+
Separator,
|
|
36
|
+
},
|
|
37
|
+
}}
|
|
38
|
+
tabMode="auto"
|
|
39
|
+
themeSwitch={{
|
|
40
|
+
enabled: false,
|
|
41
|
+
}}
|
|
42
|
+
tree={tree}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</FumadocsDocsLayout>
|
|
46
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
|
|
3
|
+
export const SlashIcon = (props: ComponentProps<"svg">) => (
|
|
4
|
+
<svg aria-hidden="true" strokeLinejoin="round" viewBox="0 0 16 16" {...props}>
|
|
5
|
+
<title>Slash</title>
|
|
6
|
+
<path
|
|
7
|
+
clipRule="evenodd"
|
|
8
|
+
d="M4.01526 15.3939L4.3107 14.7046L10.3107 0.704556L10.6061 0.0151978L11.9849 0.606077L11.6894 1.29544L5.68942 15.2954L5.39398 15.9848L4.01526 15.3939Z"
|
|
9
|
+
fill="currentColor"
|
|
10
|
+
fillRule="evenodd"
|
|
11
|
+
/>
|
|
12
|
+
</svg>
|
|
13
|
+
);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { track } from "@vercel/analytics";
|
|
4
|
+
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { toast } from "sonner";
|
|
7
|
+
import {
|
|
8
|
+
InputGroup,
|
|
9
|
+
InputGroupAddon,
|
|
10
|
+
InputGroupButton,
|
|
11
|
+
InputGroupInput,
|
|
12
|
+
InputGroupText,
|
|
13
|
+
} from "@/components/ui/input-group";
|
|
14
|
+
|
|
15
|
+
const COPY_TIMEOUT = 2000;
|
|
16
|
+
|
|
17
|
+
interface InstallerProps {
|
|
18
|
+
className?: string;
|
|
19
|
+
command: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const Installer = ({ command, className = "w-48" }: InstallerProps) => {
|
|
23
|
+
const [copied, setCopied] = useState(false);
|
|
24
|
+
|
|
25
|
+
const handleCopy = () => {
|
|
26
|
+
navigator.clipboard.writeText(command);
|
|
27
|
+
toast.success("Copied to clipboard");
|
|
28
|
+
setCopied(true);
|
|
29
|
+
|
|
30
|
+
track("Copied installer command");
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
setCopied(false);
|
|
33
|
+
}, COPY_TIMEOUT);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const Icon = copied ? CheckIcon : CopyIcon;
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<InputGroup className="h-10 bg-background font-mono shadow-none">
|
|
40
|
+
<InputGroupAddon>
|
|
41
|
+
<InputGroupText className="font-normal text-muted-foreground">
|
|
42
|
+
$
|
|
43
|
+
</InputGroupText>
|
|
44
|
+
</InputGroupAddon>
|
|
45
|
+
<InputGroupInput className={className} readOnly value={command} />
|
|
46
|
+
<InputGroupAddon align="inline-end">
|
|
47
|
+
<InputGroupButton
|
|
48
|
+
aria-label="Copy"
|
|
49
|
+
onClick={handleCopy}
|
|
50
|
+
size="icon-xs"
|
|
51
|
+
title="Copy"
|
|
52
|
+
>
|
|
53
|
+
<Icon className="size-3.5" size={14} />
|
|
54
|
+
</InputGroupButton>
|
|
55
|
+
</InputGroupAddon>
|
|
56
|
+
</InputGroup>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useTheme } from "next-themes";
|
|
4
|
+
import { use, useEffect, useId, useState } from "react";
|
|
5
|
+
|
|
6
|
+
export const Mermaid = ({ chart }: { chart: string }) => {
|
|
7
|
+
const [mounted, setMounted] = useState(false);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
setMounted(true);
|
|
11
|
+
}, []);
|
|
12
|
+
|
|
13
|
+
if (!mounted) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return <MermaidContent chart={chart} />;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const cache = new Map<string, Promise<unknown>>();
|
|
21
|
+
|
|
22
|
+
function cachePromise<T>(
|
|
23
|
+
key: string,
|
|
24
|
+
setPromise: () => Promise<T>
|
|
25
|
+
): Promise<T> {
|
|
26
|
+
const cached = cache.get(key);
|
|
27
|
+
if (cached) {
|
|
28
|
+
return cached as Promise<T>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const promise = setPromise();
|
|
32
|
+
cache.set(key, promise);
|
|
33
|
+
return promise;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function MermaidContent({ chart }: { chart: string }) {
|
|
37
|
+
const id = useId();
|
|
38
|
+
const { resolvedTheme } = useTheme();
|
|
39
|
+
const { default: mermaid } = use(
|
|
40
|
+
cachePromise("mermaid", () => import("mermaid"))
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
mermaid.initialize({
|
|
44
|
+
startOnLoad: false,
|
|
45
|
+
securityLevel: "loose",
|
|
46
|
+
fontFamily: "inherit",
|
|
47
|
+
themeCSS: "margin: 1.5rem auto 0;",
|
|
48
|
+
theme: resolvedTheme === "dark" ? "dark" : "default",
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const { svg, bindFunctions } = use(
|
|
52
|
+
cachePromise(`${chart}-${resolvedTheme}`, () =>
|
|
53
|
+
mermaid.render(id, chart.replaceAll("\\n", "\n"))
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div
|
|
59
|
+
// biome-ignore lint/security/noDangerouslySetInnerHtml: "this is needed."
|
|
60
|
+
dangerouslySetInnerHTML={{ __html: svg }}
|
|
61
|
+
ref={(container) => {
|
|
62
|
+
if (container) {
|
|
63
|
+
bindFunctions?.(container);
|
|
64
|
+
}
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
}
|