Răsfoiți Sursa

Use ReactMarkdwnComponents/NextLink

Shun Miyazawa 1 an în urmă
părinte
comite
fe9d49afe9

+ 3 - 2
apps/app/src/components/ReactMarkdownComponents/NextLink.tsx

@@ -41,11 +41,12 @@ type Props = Omit<LinkProps, 'href'> & {
   id?: string,
   id?: string,
   href?: string,
   href?: string,
   className?: string,
   className?: string,
+  onClickNextLink?: () => void,
 };
 };
 
 
 export const NextLink = (props: Props): JSX.Element => {
 export const NextLink = (props: Props): JSX.Element => {
   const {
   const {
-    id, href, children, className, ...rest
+    id, href, children, className, onClickNextLink, ...rest
   } = props;
   } = props;
 
 
   const { data: siteUrl } = useSiteUrl();
   const { data: siteUrl } = useSiteUrl();
@@ -76,7 +77,7 @@ export const NextLink = (props: Props): JSX.Element => {
 
 
   return (
   return (
     <Link {...rest} href={href} prefetch={false} legacyBehavior>
     <Link {...rest} href={href} prefetch={false} legacyBehavior>
-      <a href={href} className={className} {...dataAttributes}>{children}</a>
+      <a href={href} className={className} {...dataAttributes} onClick={onClickNextLink}>{children}</a>
     </Link>
     </Link>
   );
   );
 };
 };

+ 4 - 4
apps/app/src/features/openai/chat/components/AiChatModal/MessageCard.tsx

@@ -1,10 +1,11 @@
 import { useCallback } from 'react';
 import { useCallback } from 'react';
 
 
-import Link from 'next/link';
 import type { LinkProps } from 'next/link';
 import type { LinkProps } from 'next/link';
 import { useTranslation } from 'react-i18next';
 import { useTranslation } from 'react-i18next';
 import ReactMarkdown from 'react-markdown';
 import ReactMarkdown from 'react-markdown';
 
 
+import { NextLink } from '~/components/ReactMarkdownComponents/NextLink';
+
 import { useRagSearchModal } from '../../../client/stores/rag-search';
 import { useRagSearchModal } from '../../../client/stores/rag-search';
 
 
 import styles from './MessageCard.module.scss';
 import styles from './MessageCard.module.scss';
@@ -33,13 +34,12 @@ const NextLinkWrapper = (props: LinkProps & {children: string, href: string}): J
   }, [closeRagSearchModal]);
   }, [closeRagSearchModal]);
 
 
   return (
   return (
-    <Link {...props} onClick={onClick} prefetch={false} className="link-primary">
+    <NextLink href={props.href} onClickNextLink={onClick} className="link-primary">
       {props.children}
       {props.children}
-    </Link>
+    </NextLink>
   );
   );
 };
 };
 const AssistantMessageCard = ({ children }: { children: string }): JSX.Element => {
 const AssistantMessageCard = ({ children }: { children: string }): JSX.Element => {
-
   const { t } = useTranslation();
   const { t } = useTranslation();
 
 
   return (
   return (