mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-12 21:13:43 +08:00
Update markdown.tsx
Add _self or _blank renderers for links
This commit is contained in:
@@ -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} />;
|
||||
},
|
||||
}}
|
||||
|
Reference in New Issue
Block a user