Преглед на файлове

fix: Resolve markdown link issue

Resolved Markdown Issue
This pull request also resolves an issue where internal links were not redirecting properly in markdown, and optimizes the behavior for external links to open in a new window.
Clarence Dan преди 1 година
родител
ревизия
aeda7520fe
променени са 1 файла, в които са добавени 6 реда и са изтрити 1 реда
  1. 6 1
      app/components/markdown.tsx

+ 6 - 1
app/components/markdown.tsx

@@ -46,8 +46,13 @@ function _MarkDownContent(props: { content: string }) {
       ]}
       components={{
         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}
     </ReactMarkdown>