Update markdown.tsx

Add _self or _blank renderers for links
This commit is contained in:
Clarence Dan
2023-04-28 10:46:51 +08:00
committed by GitHub
parent 14c2135404
commit 1a0d01e5b0

View File

@@ -98,12 +98,8 @@ export function Markdown(
}}
renderers={{
link: (props) => {
// 判断链接是否为内部地址
const isInternal = /^\/(?!\/)/.test(props.href);
// 如果是内部地址使用_self否则使用_blank
const target = isInternal ? "_self" : "_blank";
return <a {...props} target={target} />;
},
}}