mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import {h} from 'preact'
2
3export function Link({
4 href,
5 className,
6 ...props
7}: {
8 href: string
9 className?: string
10} & h.JSX.HTMLAttributes<HTMLAnchorElement>) {
11 const searchParam = new URLSearchParams(window.location.search)
12 const ref_url = searchParam.get('ref_url')
13
14 const newSearchParam = new URLSearchParams()
15 newSearchParam.set('ref_src', 'embed')
16 if (ref_url) {
17 newSearchParam.set('ref_url', ref_url)
18 }
19
20 return (
21 <a
22 href={`${
23 href.startsWith('http') ? href : `https://bsky.app${href}`
24 }?${newSearchParam.toString()}`}
25 target="_blank"
26 rel="noopener noreferrer nofollow"
27 onClick={evt => evt.stopPropagation()}
28 className={`cursor-pointer ${className || ''}`}
29 {...props}
30 />
31 )
32}