From bfa8624fb45c37395c8b9506dd3312d84afcfc30 Mon Sep 17 00:00:00 2001 From: Madison Date: Sun, 28 Sep 2025 13:53:18 -0500 Subject: [PATCH 1/3] [Docs][ui][Site] - Adds open/copy buttons to pages. (#902) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit image ## High-level PR Summary This PR adds two new interactive components to the documentation pages: a "Copy Markdown" button that allows users to copy the raw markdown content of a page, and an "Open" dropdown menu that provides options to open the current page in various AI tools (Scira AI, ChatGPT, Claude, and T3 Chat). The implementation includes a new `page-actions.tsx` component file with the `LLMCopyButton` and `ViewOptions` components, and updates the documentation page layout to incorporate these new buttons in the header alongside the page title. ⏱️ Estimated Review Time: 5-15 minutes
πŸ’‘ Review Order Suggestion | Order | File Path | |-------|-----------| | 1 | `docs/src/components/page-actions.tsx` | | 2 | `docs/src/app/docs/[[...slug]]/page.tsx` |
---- > [!IMPORTANT] > Adds `LLMCopyButton` and `ViewOptions` to documentation pages for copying markdown and opening in AI tools. > > - **New Features**: > - Added `LLMCopyButton` in `page-actions.tsx` to copy markdown content to clipboard. > - Added `ViewOptions` in `page-actions.tsx` to open pages in AI tools (Scira AI, ChatGPT, Claude, T3 Chat). > - **Integration**: > - Integrated `LLMCopyButton` and `ViewOptions` into `page.tsx` header layout. > - Adjusted header layout in `page.tsx` to align title and new buttons. > > This description was created by [Ellipsis](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral) for b51bb98d4e75b64258cec34a07b6d6e3c7d7a07c. You can [customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this summary. It will automatically update as commits are pushed. ---- ## Review by RecurseML _πŸ” Review performed on [e48ffa6..3cbe5a5](https://github.com/stack-auth/stack-auth/compare/e48ffa67ee4544177d8dc980536c8906edec501e...3cbe5a58618f6163196943b40f05a8cdb09ac603)_ ✨ No bugs found, your code is sparkling clean
βœ… Files analyzed, no issues (2) β€’ `docs/src/components/page-actions.tsx` β€’ `docs/src/app/docs/[[...slug]]/page.tsx`
[![Need help? Join our Discord](https://img.shields.io/badge/Need%20help%3F%20Join%20our%20Discord-5865F2?style=plastic&logo=discord&logoColor=white)](https://discord.gg/n3SsVDAW6U) ## Summary by CodeRabbit * **New Features** * Added header actions on docs pages: a button to copy the page Markdown to clipboard and an β€œOpen” menu to launch external AI chat tools or view the source. * **Documentation** * Updated docs page header layout so the title is left-aligned with action controls on the right for easier access. --- > [!NOTE] > Adds header actions to docs pages: copy raw Markdown and open the page in external AI tools. > > - **Docs UI**: > - **New components** in `docs/src/components/page-actions.tsx`: > - `LLMCopyButton`: copies raw Markdown to clipboard with simple caching. > - `ViewOptions`: popover with links to external AI tools (Scira, ChatGPT, Claude, T3 Chat). > - **Integration** in `docs/src/app/docs/[[...slug]]/page.tsx`: > - Wraps `DocsTitle` with a header row and adds `LLMCopyButton` and `ViewOptions`. > - Passes `markdownUrl` as ``${page.url}.mdx`` for both actions. > > Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 5578cc9d37bbb501d0824935b2f0627908642cc9. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot). --------- Co-authored-by: Konsti Wohlwend --- docs/src/app/docs/[[...slug]]/page.tsx | 11 +- docs/src/components/page-actions.tsx | 231 +++++++++++++++++++++++++ 2 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 docs/src/components/page-actions.tsx 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/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} + + + ))} + + + ); +} From 10a979eb371c8e4e721ad1fa55360ea389db1dc3 Mon Sep 17 00:00:00 2001 From: Konstantin Wohlwend Date: Sun, 28 Sep 2025 14:40:58 -0500 Subject: [PATCH 2/3] Remove Loading in docs --- docs/src/app/loading.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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... -
+
); } From 8da71867d00bf7502035bba41a20891a9b1c37a6 Mon Sep 17 00:00:00 2001 From: Konstantin Wohlwend Date: Sun, 28 Sep 2025 16:02:30 -0500 Subject: [PATCH 3/3] Remove double description --- docs/templates/sdk/index.mdx | 1 - docs/templates/sdk/overview-new.mdx | 1 - 2 files changed, 2 deletions(-) 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. ---