import { AtUri } from "@atproto/api";
import { atUriToUrl } from "src/utils/mentionUtils";
import {
isDocumentCollection,
isPublicationCollection,
} from "src/utils/collectionHelpers";
/**
* Component for rendering at-uri mentions (publications and documents) as clickable links.
* NOTE: This component's styling and behavior should match the ProseMirror schema rendering
* in components/Blocks/TextBlock/schema.ts (atMention mark). If you update one, update the other.
*/
export function AtMentionLink({
atURI,
children,
className = "",
}: {
atURI: string;
children: React.ReactNode;
className?: string;
}) {
const aturi = new AtUri(atURI);
const isPublication = isPublicationCollection(aturi.collection);
const isDocument = isDocumentCollection(aturi.collection);
// Show publication icon if available
const icon =
isPublication || isDocument ? (
) : null;
return (
{icon}
{children}
);
}