"use client" import { useState } from "react" import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" import { Label } from "@/components/ui/label" import { Code, Copy, Check, ExternalLink, Moon, Sun } from "lucide-react" import { cn } from "@/lib/utils" interface EmbedCodeGeneratorProps { promptSlug: string promptTitle: string } export function EmbedCodeGenerator({ promptSlug, promptTitle }: EmbedCodeGeneratorProps) { const [theme, setTheme] = useState<"light" | "dark">("light") const [minimal, setMinimal] = useState(false) const [copied, setCopied] = useState(false) const baseUrl = typeof window !== 'undefined' ? window.location.origin : 'https://open-prompt.netlify.app' const embedUrl = `${baseUrl}/embed/${promptSlug}?theme=${theme}${minimal ? '&minimal=true' : ''}` const iframeCode = `` const copyCode = async () => { await navigator.clipboard.writeText(iframeCode) setCopied(true) setTimeout(() => setCopied(false), 2000) } return ( Embed This Prompt Add this prompt to your website, blog, or documentation {/* Options */} Theme setTheme("light")} className="gap-1" > Light setTheme("dark")} className="gap-1" > Dark Style setMinimal(false)} > Full setMinimal(true)} > Minimal {/* Preview Info */} Preview URL: {embedUrl} {/* Code Block */} {iframeCode} {copied ? ( <> Copied! > ) : ( <> Copy > )} {/* Footer Note */} The embed includes a "Powered by OpenPrompt" footer that links back to your prompt. ) }
Preview URL:
{embedUrl}
{iframeCode}
The embed includes a "Powered by OpenPrompt" footer that links back to your prompt.