From cf62711c24020360f4d874030d31fb5f966b12a9 Mon Sep 17 00:00:00 2001 From: Sinclair Chen Date: Tue, 3 May 2022 16:28:28 -0400 Subject: [PATCH] refactor SiteLink to not repeat --- web/components/site-link.tsx | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/web/components/site-link.tsx b/web/components/site-link.tsx index f3c187ef..f863cfb9 100644 --- a/web/components/site-link.tsx +++ b/web/components/site-link.tsx @@ -1,5 +1,6 @@ import clsx from 'clsx' import Link from 'next/link' +import { Children } from 'react' export const SiteLink = (props: { href: string @@ -9,24 +10,8 @@ export const SiteLink = (props: { }) => { const { href, children, onClick, className } = props - return href.startsWith('http') ? ( - { - e.stopPropagation() - if (onClick) onClick() - }} - > - {children} - - ) : ( - + return ( + {children} - + + ) +} + +function MaybeLink(props: { href: string; children: any }) { + const { href, children } = props + return href.startsWith('http') ? ( + children + ) : ( + {children} ) }