Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit e3b549b

Browse files
committed
Added markdown preview section
1 parent 3c18528 commit e3b549b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

app/page.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"use client"
22

33
import React, { useRef, useState } from "react"
4+
import dynamic from "next/dynamic"
5+
import { MarkdownPreviewProps } from "@uiw/react-markdown-preview"
46
import { Loader2 } from "lucide-react"
57
import { Configuration, OpenAIApi } from "openai"
68
import { CodeBlock, sunburst } from "react-code-blocks"
@@ -17,6 +19,13 @@ import {
1719
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
1820
import { Textarea } from "@/components/ui/textarea"
1921

22+
const MarkdownPreview = dynamic<MarkdownPreviewProps>(
23+
() => import("@uiw/react-markdown-preview"),
24+
{
25+
ssr: false,
26+
}
27+
)
28+
2029
export default function IndexPage() {
2130
let model = "gpt-3.5-turbo"
2231
let [md, setMd] = useState("# Hello")
@@ -120,7 +129,14 @@ export default function IndexPage() {
120129
</div>
121130
</TabsContent>
122131

123-
<TabsContent value="preview">Soon</TabsContent>
132+
<TabsContent value="preview">
133+
<div>
134+
<MarkdownPreview
135+
className="prose dark:prose-invert"
136+
source={md}
137+
/>
138+
</div>
139+
</TabsContent>
124140
</Tabs>
125141
</div>
126142
<div className="space-y-2">

0 commit comments

Comments
 (0)