'use client' import { useLinkPreview } from '@/lib/link-preview' const hostOf = (u: string) => { try { return new URL(u).hostname.replace(/^www\./, '') } catch { return u } } // Notion-style inline preview for a link that sits alone on its own line in // page Markdown. While the preview loads (or if nothing resolves) the card // still shows the link text/host, so content never disappears or shifts. export function LinkPreviewCard({ url, label }: { url: string; label?: string }) { const preview = useLinkPreview(url) const title = preview?.ogTitle || preview?.title || label || url const description = preview?.ogDescription || preview?.description || null return ( {preview?.ogImage ? ( // eslint-disable-next-line @next/next/no-img-element { (e.target as HTMLImageElement).style.display = 'none' }} /> ) : null} {preview?.favicon ? ( // eslint-disable-next-line @next/next/no-img-element { (e.target as HTMLImageElement).style.display = 'none' }} /> ) : null} {title} {description ? ( {description} ) : null} {hostOf(url)} ) }