"use client"; /** * The link card shown under a message, and in the composer before sending. * * Everything rendered here was fetched by the BFF. A client can choose whether * a card appears, never what it says — otherwise any link could be dressed up * as any site. */ import { X } from "lucide-react"; import { cn } from "@/lib/utils"; import type { LinkPreview } from "@/lib/chat"; export function LinkPreviewCard({ preview, onDismiss, compact = false, className, }: { preview: LinkPreview; /** When set, a dismiss control is shown (composer only). */ onDismiss?: () => void; compact?: boolean; className?: string; }) { const body = (
{preview.image_url && ( // Remote preview images come from arbitrary hosts, which next/image // would need configured per-domain. // eslint-disable-next-line @next/next/no-img-element )}
{preview.site_name && (

{preview.site_name}

)}

{preview.title || preview.url}

{!compact && preview.description && (

{preview.description}

)}
{onDismiss && ( )}
); const shell = cn( "rounded-lg border-l-2 border-current/30 bg-black/5 px-2 py-1.5 dark:bg-white/10", className, ); // In the composer the card is being edited, so it isn't a link; under a // message it is. if (onDismiss) return
{body}
; return ( {body} ); }