umer6016 commited on
Commit
a9aabde
·
1 Parent(s): 438349d

Add markdown rendering support with react-markdown

Browse files
frontend/package.json CHANGED
@@ -10,7 +10,8 @@
10
  "dependencies": {
11
  "@supabase/supabase-js": "^2.86.2",
12
  "react": "^19.2.1",
13
- "react-dom": "^19.2.1"
 
14
  },
15
  "devDependencies": {
16
  "@types/react": "^19.2.7",
@@ -18,4 +19,4 @@
18
  "@vitejs/plugin-react": "^5.1.1",
19
  "vite": "^7.2.6"
20
  }
21
- }
 
10
  "dependencies": {
11
  "@supabase/supabase-js": "^2.86.2",
12
  "react": "^19.2.1",
13
+ "react-dom": "^19.2.1",
14
+ "react-markdown": "^9.0.1"
15
  },
16
  "devDependencies": {
17
  "@types/react": "^19.2.7",
 
19
  "@vitejs/plugin-react": "^5.1.1",
20
  "vite": "^7.2.6"
21
  }
22
+ }
frontend/src/App.jsx CHANGED
@@ -1,6 +1,8 @@
1
  import { useRef, useState, useEffect } from "react";
2
  import { supabase } from "./supabaseClient";
3
 
 
 
4
  const getEnv = (key) => {
5
  if (typeof window !== "undefined" && window.__ENV__ && window.__ENV__[key]) {
6
  return window.__ENV__[key];
@@ -491,7 +493,10 @@ export default function App() {
491
  {chatMessages.length === 0 && <div className="muted">Ask anything about the scraped site.</div>}
492
  {chatMessages.map((m, idx) => (
493
  <div key={idx} className={`chat-msg ${m.role}`}>
494
- <strong>{m.role === "user" ? "You" : siteName}:</strong> {m.content}
 
 
 
495
  </div>
496
  ))}
497
  </div>
 
1
  import { useRef, useState, useEffect } from "react";
2
  import { supabase } from "./supabaseClient";
3
 
4
+ import ReactMarkdown from "react-markdown";
5
+
6
  const getEnv = (key) => {
7
  if (typeof window !== "undefined" && window.__ENV__ && window.__ENV__[key]) {
8
  return window.__ENV__[key];
 
493
  {chatMessages.length === 0 && <div className="muted">Ask anything about the scraped site.</div>}
494
  {chatMessages.map((m, idx) => (
495
  <div key={idx} className={`chat-msg ${m.role}`}>
496
+ <strong>{m.role === "user" ? "You" : siteName}:</strong>
497
+ <div className="md-content">
498
+ <ReactMarkdown>{m.content}</ReactMarkdown>
499
+ </div>
500
  </div>
501
  ))}
502
  </div>
frontend/src/styles.css CHANGED
@@ -341,6 +341,48 @@ button:disabled {
341
  }
342
  .chat-msg.user { border: 1px solid rgba(124,58,237,0.4); }
343
  .chat-msg.assistant { border: 1px solid rgba(34,211,238,0.4); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
  .muted { color: #94a3b8; }
345
  .small { font-size: 12px; }
346
  .generate-desc { margin-top: 4px; color: #9ca3af; }
 
341
  }
342
  .chat-msg.user { border: 1px solid rgba(124,58,237,0.4); }
343
  .chat-msg.assistant { border: 1px solid rgba(34,211,238,0.4); }
344
+
345
+ .md-content {
346
+ line-height: 1.5;
347
+ margin-top: 4px;
348
+ }
349
+ .md-content p {
350
+ margin: 0 0 8px;
351
+ }
352
+ .md-content p:last-child {
353
+ margin-bottom: 0;
354
+ }
355
+ .md-content ul, .md-content ol {
356
+ margin: 4px 0 8px 16px;
357
+ padding: 0;
358
+ }
359
+ .md-content li {
360
+ margin-bottom: 4px;
361
+ }
362
+ .md-content h1, .md-content h2, .md-content h3 {
363
+ margin: 10px 0 6px;
364
+ font-size: 1.1em;
365
+ font-weight: 600;
366
+ }
367
+ .md-content code {
368
+ background: rgba(0,0,0,0.3);
369
+ padding: 2px 4px;
370
+ border-radius: 4px;
371
+ font-family: monospace;
372
+ font-size: 0.9em;
373
+ }
374
+ .md-content pre {
375
+ background: rgba(0,0,0,0.3);
376
+ padding: 8px;
377
+ border-radius: 6px;
378
+ overflow-x: auto;
379
+ margin: 8px 0;
380
+ }
381
+ .md-content strong {
382
+ color: #fff;
383
+ font-weight: 700;
384
+ }
385
+
386
  .muted { color: #94a3b8; }
387
  .small { font-size: 12px; }
388
  .generate-desc { margin-top: 4px; color: #9ca3af; }