From 6fb312ccfd9cc9044a8d9837c4b89d1d7d2801a4 Mon Sep 17 00:00:00 2001
From: archer <545436317@qq.com>
Date: Tue, 20 Jun 2023 10:29:15 +0800
Subject: [PATCH] link text
---
client/src/components/Markdown/Link.tsx | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/client/src/components/Markdown/Link.tsx b/client/src/components/Markdown/Link.tsx
index db1e0164f..26e90eb4d 100644
--- a/client/src/components/Markdown/Link.tsx
+++ b/client/src/components/Markdown/Link.tsx
@@ -3,12 +3,13 @@ import { Box } from '@chakra-ui/react';
const regex = /((http|https|ftp):\/\/[^\s\u4e00-\u9fa5\u3000-\u303f\uff00-\uffef]+)/gi;
-const Link = ({ href }: { href?: string }) => {
- const decText = decodeURIComponent(href || '');
+const Link = (props: { href?: string; children?: React.ReactNode[] }) => {
+ const decText = decodeURIComponent(props.href || '');
const replaceText = decText.replace(regex, (match, p1) => {
+ const text = decText === props.children?.[0] ? p1 : props.children?.[0];
const isInternal = /^\/#/i.test(p1);
const target = isInternal ? '_self' : '_blank';
- return `${p1}`;
+ return `${text}`;
});
return ;