import type { AnchorHTMLAttributes } from "react"; import { cn } from "@/lib/utils"; import { CitationLink } from "./citation-link"; function isExternalUrl(href: string | undefined): boolean { return !!href && /^https?:\/\//.test(href); } /** Link renderer for artifact markdown: citation: prefix → CitationLink, otherwise underlined text. */ export function ArtifactLink(props: AnchorHTMLAttributes) { if (typeof props.children === "string") { const match = /^citation:(.+)$/.exec(props.children); if (match) { const [, text] = match; return {text}; } } const { className, target, rel, ...rest } = props; const external = isExternalUrl(props.href); return ( ); }