From aa1571a83c1e85980545bfbe8913d19a31ef1337 Mon Sep 17 00:00:00 2001
From: Clarence Dan <48417261+ClarenceDan@users.noreply.github.com>
Date: Fri, 28 Apr 2023 11:15:06 +0800
Subject: [PATCH] Update markdown.tsx
feat: Add option to open links in same window for internal links
---
app/components/markdown.tsx | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx
index e28d27878..3d8645659 100644
--- a/app/components/markdown.tsx
+++ b/app/components/markdown.tsx
@@ -95,13 +95,11 @@ export function Markdown(
]}
components={{
pre: PreCode,
- }}
- renderers={{
- link: (props) => {
- const isInternal = /^\/(?!\/)/.test(props.href);
- const target = isInternal ? "_self" : "_blank";
- return ;
- },
+ a: (aProps) => {
+ const isInternal = /^\/#/i.test(aProps.href);
+ const target = isInternal ? "_self" : aProps.target ?? "_blank";
+ return ;
+ },
}}
>
{props.content}