Files
zap.stream/src/element/hypertext.tsx
Alejandro Gomez 4aafb19f7e feat: mentions
2023-06-28 16:56:43 +00:00

26 lines
527 B
TypeScript

import { NostrLink } from "./nostr-link";
interface HyperTextProps {
link: string;
}
export function HyperText({ link }: HyperTextProps) {
try {
const url = new URL(link);
if (url.protocol === "nostr:" || url.protocol === "web+nostr:") {
return <NostrLink link={link} />;
} else {
<a href={link} target="_blank" rel="noreferrer">
{link}
</a>;
}
} catch {
// Ignore the error.
}
return (
<a href={link} target="_blank" rel="noreferrer">
{link}
</a>
);
}