From 1bf2073e61bb2bd2c5ded91631fae12b96f8cb33 Mon Sep 17 00:00:00 2001 From: Sinclair Chen Date: Tue, 17 May 2022 10:36:36 -0700 Subject: [PATCH] refactor SiteLink to not repeat (#125) --- web/components/site-link.tsx | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/web/components/site-link.tsx b/web/components/site-link.tsx index f3c187ef..b4e840cc 100644 --- a/web/components/site-link.tsx +++ b/web/components/site-link.tsx @@ -9,24 +9,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: React.ReactNode }) { + const { href, children } = props + return href.startsWith('http') ? ( + <>{children} + ) : ( + {children} ) }