Skip to content

Commit

Permalink
file updated and bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
olatunde1998 committed Jan 19, 2025
1 parent b171b34 commit f1f4949
Showing 1 changed file with 21 additions and 33 deletions.
54 changes: 21 additions & 33 deletions app/components/chatbot/ChatBot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from "@/components/ui/card";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Input } from "@/components/ui/input";
import { Components } from "react-markdown";

interface ChatBotProps {
toggleChat?: () => void;
Expand Down Expand Up @@ -47,6 +48,22 @@ export default function Chatbot({ toggleChat }: ChatBotProps) {
}
}, [messages]);

const MarkdownComponents: Components = {
code: ({ node, inline, className, children, ...props }: CodeProps) => {
return inline ? (
<code {...props} className="bg-gray-200 px-1 rounded">
{children}
</code>
) : (
<pre {...props} className="bg-gray-200 p-2 rounded">
<code>{children}</code>
</pre>
);
},
ul: ({ children }) => <ul className="list-disc ml-4">{children}</ul>,
ol: ({ children }) => <li className="list-decimal ml-4">{children}</li>,
};

return (
<div className="bg-green-400 text-black">
<AnimatePresence>
Expand Down Expand Up @@ -94,40 +111,11 @@ export default function Chatbot({ toggleChat }: ChatBotProps) {
}`}
>
<ReactMarkdown
children={message.content}
remarkPlugins={[remarkGfm]}
components={{
code({
node,
inline,
className,
children,
...props
}: CodeProps) {
return inline ? (
<code
{...props}
className="bg-gray-200 px-1 rounded"
>
{children}
</code>
) : (
<pre
{...props}
className="bg-gray-200 p-2 rounded"
>
<code>{children}</code>
</pre>
);
},
ul: ({ children }) => (
<ul className="list-disc ml-4">{children}</ul>
),
ol: ({ children }) => (
<li className="list-decimal ml-4">{children}</li>
),
}}
/>
components={MarkdownComponents}
>
{message.content}
</ReactMarkdown>
</div>
</div>
))}
Expand Down

0 comments on commit f1f4949

Please sign in to comment.