Skip to content

Commit

Permalink
🔧 fix(page.tsx): import ReactMarkdown to be able to render markdown c…
Browse files Browse the repository at this point in the history
…ontent in chat messages

🔧 fix(page.tsx): update message rendering to use ReactMarkdown component for displaying chat message content in markdown format
  • Loading branch information
Zaid-maker committed Aug 15, 2023
1 parent a7c2002 commit 21531e7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/(dashboard)/(routes)/code/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useProModal } from "@/hooks/use-pro-modal";
import { cn } from "@/lib/utils";
import { zodResolver } from "@hookform/resolvers/zod";
import axios from "axios";
import ReactMarkdown from "react-markdown";
import { Loader, Code } from "lucide-react";
import { useRouter } from "next/navigation";
import { ChatCompletionRequestMessage } from "openai";
Expand Down Expand Up @@ -122,7 +123,21 @@ const CodePage = () => {
)}
>
{message.role === "user" ? <UserAvatar /> : <BotAvatar />}
<p className="text-sm">{message.content}</p>
<ReactMarkdown
components={{
pre: ({ node, ...props }) => (
<div className="overflow-auto w-full my-2 bg-black/10 p-2 rounded-lg">
<pre {...props} />
</div>
),
code: ({ node, ...props }) => (
<code className="bg-black/10 rounded-lg p-1" {...props} />
),
}}
className="text-sm overflow-hidden leading-7"
>
{message.content || ""}
</ReactMarkdown>
</div>
))}
</div>
Expand Down

0 comments on commit 21531e7

Please sign in to comment.