Skip to content

Commit 4df842e

Browse files
committed
fix: fix basic markdown usage
1 parent 638c940 commit 4df842e

File tree

3 files changed

+7
-32
lines changed

3 files changed

+7
-32
lines changed

src/components/Chat.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function Chat() {
3131
<ChatBubble variant="sent">
3232
<ChatBubbleAvatar fallback="User" className="w-14" />
3333
<ChatBubbleMessage variant="sent" className="bg-zinc-700">
34-
<Markdown className="text-gray-300">
34+
<Markdown isInverted>
3535
{sanitizeQuestionPrompt({
3636
question: question?.message ?? "",
3737
answer: answer?.message ?? "",

src/components/Help.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function Help() {
3030
} catch (error) {
3131
console.error("Error loading help content:", error);
3232
setContent(
33-
"# Error\nFailed to load help content. Please try again later."
33+
"# Error\nFailed to load help content. Please try again later.",
3434
);
3535
}
3636
};
@@ -40,20 +40,7 @@ export function Help() {
4040

4141
return (
4242
<div className="max-w-5xl bg-white rounded-lg px-6 mx-auto">
43-
<Markdown
44-
className="prose prose-lg max-w-none
45-
prose-headings:text-gray-900
46-
prose-h1:text-3xl prose-h1:font-bold prose-h1:mb-8
47-
prose-h2:text-2xl prose-h2:font-semibold prose-h2:mt-8 prose-h2:mb-4
48-
prose-h3:text-xl prose-h3:font-medium prose-h3:mt-6 prose-h3:mb-3
49-
prose-p:text-gray-600 prose-p:leading-relaxed
50-
prose-code:text-blue-600
51-
prose-pre:bg-gray-900 prose-pre:rounded-lg prose-pre:p-4
52-
prose-pre:shadow-md
53-
"
54-
>
55-
{content}
56-
</Markdown>
43+
<Markdown>{content}</Markdown>
5744
</div>
5845
);
5946
}

src/components/Markdown.tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import remarkGfm from "remark-gfm";
22
import ReactMarkdown from "react-markdown";
33
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
44
import { oneDark } from "react-syntax-highlighter/dist/esm/styles/prism";
5-
import { cn } from "@/lib/utils";
65
import { CopyToClipboard } from "./CopyToClipboard";
76
import hljs from "highlight.js";
87

@@ -33,7 +32,7 @@ const LANGUAGES_SUBSET_DETECTION = [
3332

3433
interface Props {
3534
children: string;
36-
className?: string;
35+
isInverted?: boolean;
3736
}
3837

3938
const customStyle = {
@@ -52,9 +51,11 @@ const customStyle = {
5251
boxSizing: "border-box",
5352
},
5453
};
55-
export function Markdown({ children, className = "" }: Props) {
54+
55+
export function Markdown({ children, isInverted = false }: Props) {
5656
return (
5757
<ReactMarkdown
58+
className={`max-w-none prose prose-pre:shadow-md prose-pre:rounded-lg prose-pre:p-4 prose-p:leading-relaxed prose-h1:text-3xl prose-h1:font-bold prose-h1:mb-8 prose-h2:text-2xl prose-h2:font-semibold prose-h2:mt-8 prose-h2:mb-4 prose-h3:text-xl prose-h3:font-medium prose-h3:mt-6 prose-h3:mb-3 ${isInverted ? "prose-invert" : ""}`}
5859
components={{
5960
code({ className, children, ...props }) {
6061
if (!children) return null;
@@ -84,18 +85,6 @@ export function Markdown({ children, className = "" }: Props) {
8485
</div>
8586
);
8687
},
87-
p({ children }) {
88-
return (
89-
<p
90-
className={cn(
91-
"text-gray-600 leading-relaxed mt-6 mb-3",
92-
className,
93-
)}
94-
>
95-
{children}
96-
</p>
97-
);
98-
},
9988
pre({ children }) {
10089
return <div className="not-prose">{children}</div>;
10190
},
@@ -116,7 +105,6 @@ export function Markdown({ children, className = "" }: Props) {
116105
},
117106
}}
118107
remarkPlugins={[remarkGfm]}
119-
className={className}
120108
>
121109
{children}
122110
</ReactMarkdown>

0 commit comments

Comments
 (0)