Procházet zdrojové kódy

Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web

GH Action - Upstream Sync před 1 rokem
rodič
revize
14b3f300ae
1 změnil soubory, kde provedl 6 přidání a 1 odebrání
  1. 6 1
      app/components/markdown.tsx

+ 6 - 1
app/components/markdown.tsx

@@ -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>