diff --git a/docs/src/app/docs/[[...slug]]/page.tsx b/docs/src/app/docs/[[...slug]]/page.tsx index 02771b7bc..0f4d56322 100644 --- a/docs/src/app/docs/[[...slug]]/page.tsx +++ b/docs/src/app/docs/[[...slug]]/page.tsx @@ -4,6 +4,7 @@ import { DocsPage, DocsTitle, } from '@/components/layouts/page'; +import { LLMCopyButton, ViewOptions } from '@/components/page-actions'; import { getMDXComponents } from '@/mdx-components'; import { createRelativeLink } from 'fumadocs-ui/mdx'; import { source } from 'lib/source'; @@ -27,7 +28,15 @@ export default async function Page(props: { return ( - {page.data.title} +
+ {page.data.title} +
+ + +
+
{/* Only show description if it exists and is not empty */} {page.data.description && page.data.description.trim() && ( {page.data.description} diff --git a/docs/src/app/loading.tsx b/docs/src/app/loading.tsx index ca1dfdb06..04f47a424 100644 --- a/docs/src/app/loading.tsx +++ b/docs/src/app/loading.tsx @@ -1,7 +1,5 @@ export default function Loading() { return ( -
- Loading... -
+
); } diff --git a/docs/src/components/page-actions.tsx b/docs/src/components/page-actions.tsx new file mode 100644 index 000000000..e4683b7ff --- /dev/null +++ b/docs/src/components/page-actions.tsx @@ -0,0 +1,231 @@ +'use client'; +import { cva } from 'class-variance-authority'; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from 'fumadocs-ui/components/ui/popover'; +import { useCopyButton } from 'fumadocs-ui/utils/use-copy-button'; +import { + Check, + ChevronDown, + Copy, + ExternalLinkIcon, + MessageCircleIcon, +} from 'lucide-react'; +import { useMemo, useState } from 'react'; +import { cn } from '../lib/cn'; +import { buttonVariants } from './ui/button'; + +const cache = new Map(); + +export function LLMCopyButton({ + /** + * A URL to fetch the raw Markdown/MDX content of page + */ + markdownUrl, +}: { + markdownUrl: string, +}) { + const [isLoading, setLoading] = useState(false); + const [checked, onClick] = useCopyButton(async () => { + const cached = cache.get(markdownUrl); + if (cached) return await navigator.clipboard.writeText(cached); + + setLoading(true); + + try { + await navigator.clipboard.write([ + new ClipboardItem({ + 'text/plain': fetch(markdownUrl).then(async (res) => { + const content = await res.text(); + cache.set(markdownUrl, content); + + return content; + }), + }), + ]); + } finally { + setLoading(false); + } + }); + + return ( + + ); +} + +const optionVariants = cva( + 'text-sm p-2 rounded-lg inline-flex items-center gap-2 hover:text-fd-accent-foreground hover:bg-fd-accent [&_svg]:size-4', +); + +export function ViewOptions({ + markdownUrl, +}: { + /** + * A URL to the raw Markdown/MDX content of page + */ + markdownUrl: string, +}) { + const items = useMemo(() => { + const fullMarkdownUrl = + typeof window !== 'undefined' + ? new URL(markdownUrl, window.location.origin) + : 'loading'; + const q = `Read ${fullMarkdownUrl}, I want to ask questions about it.`; + + return [ + { + title: 'Open in Scira AI', + href: `https://scira.ai/?${new URLSearchParams({ + q, + })}`, + icon: ( + + Scira AI + + + + + + + + + ), + }, + { + title: 'Open in ChatGPT', + href: `https://chatgpt.com/?${new URLSearchParams({ + hints: 'search', + q, + })}`, + icon: ( + + OpenAI + + + ), + }, + { + title: 'Open in Claude', + href: `https://claude.ai/new?${new URLSearchParams({ + q, + })}`, + icon: ( + + Anthropic + + + ), + }, + { + title: 'Open in T3 Chat', + href: `https://t3.chat/new?${new URLSearchParams({ + q, + })}`, + icon: , + }, + ]; + }, [markdownUrl]); + + return ( + + + Open + + + + {items.map((item) => ( + + {item.icon} + {item.title} + + + ))} + + + ); +} diff --git a/docs/templates/sdk/index.mdx b/docs/templates/sdk/index.mdx index e3da074f9..a85c720d8 100644 --- a/docs/templates/sdk/index.mdx +++ b/docs/templates/sdk/index.mdx @@ -1,6 +1,5 @@ --- title: SDK Overview -description: This is the SDK reference for Stack Auth's Next.js SDK. --- diff --git a/docs/templates/sdk/overview-new.mdx b/docs/templates/sdk/overview-new.mdx index 1f000d144..8609f00b4 100644 --- a/docs/templates/sdk/overview-new.mdx +++ b/docs/templates/sdk/overview-new.mdx @@ -1,6 +1,5 @@ --- title: SDK Overview -description: This is the SDK reference for Stack Auth's Next.js SDK. ---