From aeda7520fea361474c2177539d203a75226af358 Mon Sep 17 00:00:00 2001 From: Clarence Dan <48417261+ClarenceDan@users.noreply.github.com> Date: Tue, 2 May 2023 11:18:18 +0800 Subject: [PATCH] fix: Resolve markdown link issue Resolved Markdown Issue This pull request also resolves an issue where internal links were not redirecting properly in markdown, and optimizes the behavior for external links to open in a new window. --- app/components/markdown.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index b5805e50314..49bb581df03 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -46,8 +46,13 @@ function _MarkDownContent(props: { content: string }) { ]} components={{ pre: PreCode, + a: (aProps) => { + const href = aProps.href || ""; + const isInternal = /^\/#/i.test(href); + const target = isInternal ? "_self" : aProps.target ?? "_blank"; + return ; + }, }} - linkTarget={"_blank"} > {props.content}