Don't wrap external link with next/link

This commit is contained in:
jahooma 2021-12-31 13:17:32 -06:00
parent 6eda71286c
commit f1977f26ea
4 changed files with 19 additions and 10 deletions

View File

@ -15,7 +15,7 @@ import { User } from '../lib/firebase/users'
import { UserLink } from './user-page'
import { Linkify } from './linkify'
import { Col } from './layout/col'
import { SiteLink } from './link'
import { SiteLink } from './site-link'
export function ContractDetails(props: { contract: Contract }) {
const { contract } = props

View File

@ -1,5 +1,5 @@
import Link from 'next/link'
import { Fragment } from 'react'
import { SiteLink } from './site-link'
// Return a JSX span, linkifying @username, #hashtags, and https://...
export function Linkify(props: { text: string }) {
@ -20,12 +20,10 @@ export function Linkify(props: { text: string }) {
return (
<>
{whitespace}
<Link href={href}>
<a className="text-indigo-700 hover:underline hover:decoration-2">
<SiteLink className="text-indigo-700" href={href}>
{symbol}
{tag}
</a>
</Link>
</SiteLink>
</>
)
})

View File

@ -8,7 +8,18 @@ export const SiteLink = (props: {
}) => {
const { href, children, className } = props
return (
return href.startsWith('http') ? (
<a
href={href}
className={clsx(
'hover:underline hover:decoration-indigo-400 hover:decoration-2',
className
)}
onClick={(e) => e.stopPropagation()}
>
{children}
</a>
) : (
<Link href={href}>
<a
className={clsx(

View File

@ -5,7 +5,7 @@ import { Row } from './layout/row'
import { formatMoney } from '../lib/util/format'
import { SEO } from './SEO'
import { Page } from './page'
import { SiteLink } from './link'
import { SiteLink } from './site-link'
export function UserLink(props: { username: string; className?: string }) {
const { username, className } = props