From f1977f26ead5dc0e7f0290292e9cf7b5ce2c9a12 Mon Sep 17 00:00:00 2001 From: jahooma Date: Fri, 31 Dec 2021 13:17:32 -0600 Subject: [PATCH] Don't wrap external link with next/link --- web/components/contracts-list.tsx | 2 +- web/components/linkify.tsx | 12 +++++------- web/components/{link.tsx => site-link.tsx} | 13 ++++++++++++- web/components/user-page.tsx | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) rename web/components/{link.tsx => site-link.tsx} (63%) diff --git a/web/components/contracts-list.tsx b/web/components/contracts-list.tsx index aed8e3f4..b40c926a 100644 --- a/web/components/contracts-list.tsx +++ b/web/components/contracts-list.tsx @@ -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 diff --git a/web/components/linkify.tsx b/web/components/linkify.tsx index fd1be879..df6bb98d 100644 --- a/web/components/linkify.tsx +++ b/web/components/linkify.tsx @@ -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} - - - {symbol} - {tag} - - + + {symbol} + {tag} + ) }) diff --git a/web/components/link.tsx b/web/components/site-link.tsx similarity index 63% rename from web/components/link.tsx rename to web/components/site-link.tsx index c462d611..a3a5a01b 100644 --- a/web/components/link.tsx +++ b/web/components/site-link.tsx @@ -8,7 +8,18 @@ export const SiteLink = (props: { }) => { const { href, children, className } = props - return ( + return href.startsWith('http') ? ( + e.stopPropagation()} + > + {children} + + ) : (