diff --git a/app/page.tsx b/app/page.tsx index 0be10ce..6ed2dce 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -18,6 +18,7 @@ import { toast } from 'sonner'; import { motion, AnimatePresence } from 'framer-motion'; import Image from 'next/image'; import { suggestQuestions, Message } from './actions'; +import { copyToClipboard } from '@/lib/utils' import { SearchIcon, ChevronDown, @@ -26,7 +27,8 @@ import { ArrowRight, Globe, AlignLeft, - Newspaper + Newspaper, + Copy, } from 'lucide-react'; import { HoverCard, @@ -559,16 +561,36 @@ export default function Home() { {messages.map((message, index) => (
{message.role === 'assistant' && message.content && ( -
-
- -

Answer

+
+
+
+ +

Answer

+
+
-
+
diff --git a/lib/utils.ts b/lib/utils.ts index d084cca..8460127 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -4,3 +4,10 @@ import { twMerge } from "tailwind-merge" export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } + +export async function copyToClipboard(text: string): Promise { + if (!navigator.clipboard) { + throw new Error('Clipboard API not available'); + } + await navigator.clipboard.writeText(text); +} \ No newline at end of file