mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
feat(problem-description): Use compileMDX with remarkGfm for MDX rendering
This commit is contained in:
parent
8498f57fbc
commit
3f3b153c4b
@ -1,5 +1,6 @@
|
|||||||
import { Suspense } from "react";
|
import { Suspense } from "react";
|
||||||
import { MDXRemote } from "next-mdx-remote/rsc";
|
import remarkGfm from "remark-gfm";
|
||||||
|
import { compileMDX } from "next-mdx-remote/rsc";
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
||||||
|
|
||||||
@ -7,15 +8,29 @@ interface ProblemDescriptionProps {
|
|||||||
mdxSource: string;
|
mdxSource: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ProblemDescription({ mdxSource }: ProblemDescriptionProps) {
|
export async function ProblemDescription({ mdxSource }: ProblemDescriptionProps) {
|
||||||
return (
|
try {
|
||||||
<ScrollArea className="[&>[data-radix-scroll-area-viewport]]:max-h-[calc(100vh-56px)]">
|
const { content } = await compileMDX({
|
||||||
<Suspense fallback={<Skeleton className="h-full w-full" />}>
|
source: mdxSource,
|
||||||
<div className="markdown-body">
|
options: {
|
||||||
<MDXRemote source={mdxSource} />
|
mdxOptions: {
|
||||||
</div>
|
remarkPlugins: [remarkGfm],
|
||||||
</Suspense>
|
},
|
||||||
<ScrollBar orientation="horizontal" />
|
},
|
||||||
</ScrollArea>
|
});
|
||||||
);
|
|
||||||
|
return (
|
||||||
|
<ScrollArea className="[&>[data-radix-scroll-area-viewport]]:max-h-[calc(100vh-56px)]">
|
||||||
|
<Suspense fallback={<Skeleton className="h-full w-full" />}>
|
||||||
|
<div className="markdown-body">
|
||||||
|
{content}
|
||||||
|
</div>
|
||||||
|
</Suspense>
|
||||||
|
<ScrollBar orientation="horizontal" />
|
||||||
|
</ScrollArea>
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error compiling MDX:", error);
|
||||||
|
return <Skeleton className="h-full w-full" />;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user