mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-11 20:43:42 +08:00
Update markdown.tsx
feat: Add option to open links in same window for internal links
This commit is contained in:
@@ -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 {...props} target={target} />;
|
||||
},
|
||||
a: (aProps) => {
|
||||
const isInternal = /^\/#/i.test(aProps.href);
|
||||
const target = isInternal ? "_self" : aProps.target ?? "_blank";
|
||||
return <a {...aProps} target={target} />;
|
||||
},
|
||||
}}
|
||||
>
|
||||
{props.content}
|
||||
|
Reference in New Issue
Block a user