Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
feat(docs): add Copy Page button for AI-friendly content
Sushmithamallesh358739fe3975
diff --git a/docs/app/(home)/docs/[[...slug]]/page.tsx b/docs/app/(home)/docs/[[...slug]]/page.tsxindex b5c0d9c41..f58a60a3d 100644--- a/docs/app/(home)/docs/[[...slug]]/page.tsx+++ b/docs/app/(home)/docs/[[...slug]]/page.tsx@@ -9,6 +9,7 @@ import { notFound } from 'next/navigation';import { getMDXComponents } from '@/mdx-components';import type { Metadata } from 'next';import { createRelativeLink } from 'fumadocs-ui/mdx';+import { CopyPage } from '@/components/copy-page';export default async function Page(props: PageProps<'/docs/[[...slug]]'>) {const params = await props.params;@@ -22,7 +23,10 @@ export default async function Page(props: PageProps<'/docs/[[...slug]]'>) {return (<DocsPage toc={data.toc} full={data.full} footer={{ enabled: false }} tableOfContentPopover={{ enabled: false }}><DocsTitle>{data.title}</DocsTitle>- <DocsDescription className="mb-4">{data.description}</DocsDescription>+ <DocsDescription>{data.description}</DocsDescription>+ <div className="flex items-center gap-2 mt-2 mb-6">+ <CopyPage path={page.url} />+ </div><DocsBody><MDXcomponents={getMDXComponents({diff --git a/docs/components/copy-page.tsx b/docs/components/copy-page.tsxnew file mode 100644index 000000000..fee3836fb--- /dev/null+++ b/docs/components/copy-page.tsx@@ -0,0 +1,52 @@+'use client';++import { useState } from 'react';+import { Copy, Check, Loader2 } from 'lucide-react';++interface CopyPageProps {+ /** The URL path to fetch markdown from (e.g., /docs/quickstart) */+ path: string;+}++/**+ * Button that copies the current page's markdown content to clipboard.+ * Fetches from the .md endpoint for clean, AI-friendly content.+ */+export function CopyPage({ path }: CopyPageProps) {+ const [state, setState] = useState<'idle' | 'loading' | 'copied'>('idle');++ const handleCopy = async () => {+ setState('loading');++ try {+ const response = await fetch(`${path}.md`);+ if (!response.ok) throw new Error('Failed to fetch');++ const markdown = await response.text();+ await navigator.clipboard.writeText(markdown);++ setState('copied');+ setTimeout(() => setState('idle'), 2000);+ } catch {+ setState('idle');+ }+ };++ return (+ <button+ onClick={handleCopy}+ disabled={state === 'loading'}+ className="inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-fd-muted-foreground hover:text-fd-foreground bg-fd-secondary hover:bg-fd-accent rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-500 focus-visible:ring-offset-2 disabled:opacity-50"+ aria-label="Copy page as markdown"+ >+ {state === 'loading' ? (+ <Loader2 className="w-4 h-4 animate-spin" aria-hidden="true" />+ ) : state === 'copied' ? (+ <Check className="w-4 h-4 text-green-500" aria-hidden="true" />+ ) : (+ <Copy className="w-4 h-4" aria-hidden="true" />+ )}+ {state === 'copied' ? 'Copied!' : 'Copy page'}+ </button>+ );+}