about summary refs log tree commit diff
path: root/bskyembed/src/components/link.tsx
blob: db752542b5057ca0c3b450094c106a33dcd547f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import {h} from 'preact'

export function Link({
  href,
  className,
  ...props
}: {
  href: string
  className?: string
} & h.JSX.HTMLAttributes<HTMLAnchorElement>) {
  const newSearchParam = new URLSearchParams()
  newSearchParam.set('ref_src', 'embed')

  return (
    <a
      href={`${
        href.startsWith('http') ? href : `https://bsky.app${href}`
      }?${newSearchParam.toString()}`}
      target="_blank"
      rel="noopener noreferrer nofollow"
      onClick={evt => evt.stopPropagation()}
      className={`cursor-pointer ${className || ''}`}
      {...props}
    />
  )
}