From c569bde6d0c645cf9dc7d7c503f2ceb859f3c764 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sat, 11 Dec 2021 21:52:31 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=20(link)=20anchor=20links=20hav?= =?UTF-8?q?e=20default=20use?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useLinks.hook.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hooks/useLinks.hook.ts b/src/hooks/useLinks.hook.ts index 57ea2e4..e9816b8 100644 --- a/src/hooks/useLinks.hook.ts +++ b/src/hooks/useLinks.hook.ts @@ -7,8 +7,6 @@ export const useLinks = (className: string, sha?: string) => { const store = useUserRepoStore() const linkNote: EventListener = (event) => { - event.preventDefault() - event.stopPropagation() const target = event.target as HTMLElement const href = target.getAttribute('href') @@ -16,6 +14,13 @@ export const useLinks = (className: string, sha?: string) => { return } + if (href.startsWith('#')) { + return + } + + event.preventDefault() + event.stopPropagation() + if (isExternalLink(href)) { window.open(href, '_blank') return