manifold/web/components/site-link.tsx

39 lines
914 B
TypeScript
Raw Normal View History

2021-12-30 20:03:32 +00:00
import clsx from 'clsx'
import Link from 'next/link'
export const SiteLink = (props: {
href: string
children?: any
2021-12-30 20:03:32 +00:00
className?: string
}) => {
const { href, children, className } = props
return href.startsWith('http') ? (
<a
href={href}
className={clsx(
'z-10 break-words hover:underline hover:decoration-indigo-400 hover:decoration-2',
className
)}
2022-02-15 02:27:43 +00:00
style={{ /* For iOS safari */ wordBreak: 'break-word' }}
target="_blank"
onClick={(e) => e.stopPropagation()}
>
{children}
</a>
) : (
2021-12-30 20:03:32 +00:00
<Link href={href}>
<a
className={clsx(
'z-10 break-words hover:underline hover:decoration-indigo-400 hover:decoration-2',
2021-12-30 20:03:32 +00:00
className
)}
2022-02-15 02:27:43 +00:00
style={{ /* For iOS safari */ wordBreak: 'break-word' }}
2021-12-30 20:03:32 +00:00
onClick={(e) => e.stopPropagation()}
>
{children}
</a>
</Link>
)
}