{ "name": "source", "type": "registry:ui", "registryDependencies": [ "hover-card" ], "dependencies": [], "devDependencies": [], "tailwind": {}, "cssVars": { "light": {}, "dark": {} }, "description": "Displays website sources used by AI-generated content, showing URL details, titles, and descriptions on hover.", "files": [ { "path": "source.tsx", "content": "\"use client\"\n\nimport {\n HoverCard,\n HoverCardContent,\n HoverCardTrigger,\n} from \"@/components/ui/hover-card\"\nimport { cn } from \"@/lib/utils\"\nimport { createContext, useContext } from \"react\"\n\nconst SourceContext = createContext<{\n href: string\n domain: string\n} | null>(null)\n\nfunction useSourceContext() {\n const ctx = useContext(SourceContext)\n if (!ctx) throw new Error(\"Source.* must be used inside \")\n return ctx\n}\n\nexport type SourceProps = {\n href: string\n children: React.ReactNode\n}\n\nexport function Source({ href, children }: SourceProps) {\n let domain = \"\"\n try {\n domain = new URL(href).hostname\n } catch {\n domain = href.split(\"/\").pop() || href\n }\n\n return (\n \n \n {children}\n \n \n )\n}\n\nexport type SourceTriggerProps = {\n label?: string | number\n showFavicon?: boolean\n className?: string\n}\n\nexport function SourceTrigger({\n label,\n showFavicon = false,\n className,\n}: SourceTriggerProps) {\n const { href, domain } = useSourceContext()\n const labelToShow = label ?? domain.replace(\"www.\", \"\")\n\n return (\n \n \n {showFavicon && (\n \n )}\n {labelToShow}\n \n \n )\n}\n\nexport type SourceContentProps = {\n title: string\n description: string\n className?: string\n}\n\nexport function SourceContent({\n title,\n description,\n className,\n}: SourceContentProps) {\n const { href, domain } = useSourceContext()\n\n return (\n \n \n
\n \n
\n {domain.replace(\"www.\", \"\")}\n
\n
\n
{title}
\n
\n {description}\n
\n \n
\n )\n}\n", "type": "registry:ui" } ] }