import { NostrPrefix } from "@snort/nostr";
import { Link } from "react-router-dom";
import Mention from "Element/Mention";
import { eventLink, parseNostrLink } from "Util";
export default function NostrLink({ link }: { link: string }) {
const nav = parseNostrLink(link);
if (nav?.type === NostrPrefix.PublicKey || nav?.type === NostrPrefix.Profile) {
return ;
} else if (nav?.type === NostrPrefix.Note || nav?.type === NostrPrefix.Event) {
const evLink = eventLink(nav.id, nav.relays);
return (
e.stopPropagation()} state={{ from: location.pathname }}>
#{evLink.split("/").at(-1)?.substring(0, 12)}
);
} else {
return (
e.stopPropagation()} target="_blank" rel="noreferrer" className="ext">
{link}
);
}
}