From a268ce345c4f0efa512e05e9e6304f953d9edc4c Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Sat, 30 Aug 2025 20:48:26 +0530 Subject: [PATCH] feat(message-rendering): create citation component Create new citation component to fix errors with tailwind not compiling CSS classes for the anchor tag --- src/components/Citation.tsx | 19 +++++++++++++++++++ src/components/MessageBox.tsx | 5 ++++- src/lib/hooks/useChat.tsx | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/components/Citation.tsx diff --git a/src/components/Citation.tsx b/src/components/Citation.tsx new file mode 100644 index 0000000..25cc064 --- /dev/null +++ b/src/components/Citation.tsx @@ -0,0 +1,19 @@ +const Citation = ({ + href, + children, +}: { + href: string; + children: React.ReactNode; +}) => { + return ( + + {children} + + ); +}; + +export default Citation; diff --git a/src/components/MessageBox.tsx b/src/components/MessageBox.tsx index e16f891..c5dcbb7 100644 --- a/src/components/MessageBox.tsx +++ b/src/components/MessageBox.tsx @@ -20,6 +20,7 @@ import SearchVideos from './SearchVideos'; import { useSpeech } from 'react-text-to-speech'; import ThinkBox from './ThinkBox'; import { useChat, Section } from '@/lib/hooks/useChat'; +import Citation from './Citation'; const ThinkTagProcessor = ({ children, @@ -46,7 +47,6 @@ const MessageBox = ({ }) => { const { loading, chatTurns, sendMessage, rewrite } = useChat(); - // Use the pre-processed data from section const parsedMessage = section.parsedAssistantMessage || ''; const speechMessage = section.speechMessage || ''; const thinkingEnded = section.thinkingEnded; @@ -61,6 +61,9 @@ const MessageBox = ({ thinkingEnded: thinkingEnded, }, }, + citation: { + component: Citation, + }, }, }; diff --git a/src/lib/hooks/useChat.tsx b/src/lib/hooks/useChat.tsx index 0b8b143..fc94174 100644 --- a/src/lib/hooks/useChat.tsx +++ b/src/lib/hooks/useChat.tsx @@ -446,7 +446,7 @@ export const ChatProvider = ({ const url = source?.metadata?.url; if (url) { - return `${numStr}`; + return `${numStr}`; } else { return ``; }