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
docs: add copy-to-clipboard on heading anchor click
Sushmithamallesh7dfe69150e95
diff --git a/docs/components/heading.tsx b/docs/components/heading.tsxnew file mode 100644index 000000000..879db6c09--- /dev/null+++ b/docs/components/heading.tsx@@ -0,0 +1,60 @@+'use client';++import { cn } from '@fumadocs/ui/cn';+import { Link, Check } from 'lucide-react';+import { useState, type ComponentPropsWithoutRef } from 'react';++type HeadingProps = ComponentPropsWithoutRef<'h1'> & {+ as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';+};++export function Heading({ as, className, ...props }: HeadingProps) {+ const As = as ?? 'h1';++ if (!props.id) return <As className={className} {...props} />;++ return (+ <As+ className={cn(+ 'flex scroll-m-28 flex-row items-center gap-2',+ className,+ )}+ {...props}+ >+ <HeadingAnchor id={props.id}>{props.children}</HeadingAnchor>+ </As>+ );+}++function HeadingAnchor({ id, children }: { id: string; children: React.ReactNode }) {+ const [copied, setCopied] = useState(false);++ const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {+ e.preventDefault();+ const url = `${window.location.origin}${window.location.pathname}#${id}`;+ window.history.replaceState(null, '', `#${id}`);+ navigator.clipboard.writeText(url).then(() => {+ setCopied(true);+ setTimeout(() => setCopied(false), 2000);+ });+ };++ return (+ <>+ <a data-card="" href={`#${id}`} className="peer" onClick={handleClick}>+ {children}+ </a>+ {copied ? (+ <Check+ aria-hidden+ className="size-3.5 shrink-0 text-green-500 transition-opacity"+ />+ ) : (+ <Link+ aria-hidden+ className="size-3.5 shrink-0 text-fd-muted-foreground opacity-0 transition-opacity peer-hover:opacity-100"+ />+ )}+ </>+ );+}diff --git a/docs/mdx-components.tsx b/docs/mdx-components.tsxindex 006709b6e..ea817068d 100644--- a/docs/mdx-components.tsx+++ b/docs/mdx-components.tsx@@ -1,5 +1,6 @@import defaultMdxComponents from 'fumadocs-ui/mdx';import type { MDXComponents } from 'mdx/types';+import { Heading } from '@/components/heading';import { YouTube } from '@/components/youtube';import { Tabs, Tab, TabsList, TabsTrigger, TabsContent } from 'fumadocs-ui/components/tabs';import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';@@ -35,6 +36,9 @@ import {export function getMDXComponents(components?: MDXComponents): MDXComponents {return {...defaultMdxComponents,+ h2: (props) => <Heading as="h2" {...props} />,+ h3: (props) => <Heading as="h3" {...props} />,+ h4: (props) => <Heading as="h4" {...props} />,img: (props) => <ImageZoom {...(props as any)} />,YouTube,Tabs,