Skip to content

Commit 987ec62

Browse files
committed
fix raw markdown flash on the initial chat load
1 parent 43de976 commit 987ec62

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

apps/docs/components/ai/markdown.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import { Fragment, jsx, jsxs } from 'react/jsx-runtime';
1515
import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock';
1616
import defaultMdxComponents from 'fumadocs-ui/mdx';
17+
import { Skeleton } from '../ui/Skeleton';
1718

1819
export interface Processor {
1920
process: (content: string) => Promise<ReactNode>;
@@ -65,7 +66,7 @@ export function Markdown({ text }: { text: string }) {
6566
const deferredText = useDeferredValue(text);
6667

6768
return (
68-
<Suspense fallback={text}>
69+
<Suspense fallback={<Skeleton />}>
6970
<Renderer text={deferredText} />
7071
</Suspense>
7172
);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export function Skeleton({ lines = 4 }: { lines?: number }) {
2+
return (
3+
<div className="animate-pulse space-y-2">
4+
{Array.from({ length: lines }).map((_, i) => (
5+
<div
6+
key={i}
7+
className={`rounded bg-fd-muted-foreground/10 ${i === 0 ? 'h-4 w-3/4' : 'h-3 w-full'}`}
8+
/>
9+
))}
10+
</div>
11+
);
12+
}

0 commit comments

Comments
 (0)