mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-12 13:03:43 +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={{
|
components={{
|
||||||
pre: PreCode,
|
pre: PreCode,
|
||||||
}}
|
a: (aProps) => {
|
||||||
renderers={{
|
const isInternal = /^\/#/i.test(aProps.href);
|
||||||
link: (props) => {
|
const target = isInternal ? "_self" : aProps.target ?? "_blank";
|
||||||
const isInternal = /^\/(?!\/)/.test(props.href);
|
return <a {...aProps} target={target} />;
|
||||||
const target = isInternal ? "_self" : "_blank";
|
},
|
||||||
return <a {...props} target={target} />;
|
|
||||||
},
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{props.content}
|
{props.content}
|
||||||
|
Reference in New Issue
Block a user