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.
main
Clarence Dan 2 years ago committed by GitHub
parent 56ef8e3ebf
commit aeda7520fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -46,8 +46,13 @@ function _MarkDownContent(props: { content: string }) {
]} ]}
components={{ components={{
pre: PreCode, pre: PreCode,
a: (aProps) => {
const href = aProps.href || "";
const isInternal = /^\/#/i.test(href);
const target = isInternal ? "_self" : aProps.target ?? "_blank";
return <a {...aProps} target={target} />;
},
}} }}
linkTarget={"_blank"}
> >
{props.content} {props.content}
</ReactMarkdown> </ReactMarkdown>

Loading…
Cancel
Save