about summary refs log tree commit diff
path: root/bskyembed/src/components/link.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'bskyembed/src/components/link.tsx')
-rw-r--r--bskyembed/src/components/link.tsx21
1 files changed, 21 insertions, 0 deletions
diff --git a/bskyembed/src/components/link.tsx b/bskyembed/src/components/link.tsx
new file mode 100644
index 000000000..7226ecf3d
--- /dev/null
+++ b/bskyembed/src/components/link.tsx
@@ -0,0 +1,21 @@
+import {h} from 'preact'
+
+export function Link({
+  href,
+  className,
+  ...props
+}: {
+  href: string
+  className?: string
+} & h.JSX.HTMLAttributes<HTMLAnchorElement>) {
+  return (
+    <a
+      href={href.startsWith('http') ? href : `https://bsky.app${href}`}
+      target="_blank"
+      rel="noopener noreferrer nofollow"
+      onClick={evt => evt.stopPropagation()}
+      className={`cursor-pointer ${className || ''}`}
+      {...props}
+    />
+  )
+}