2025-02-20 09:58:49 +00:00
|
|
|
import { Suspense } from "react";
|
2025-02-20 10:46:20 +00:00
|
|
|
import remarkGfm from "remark-gfm";
|
|
|
|
import { compileMDX } from "next-mdx-remote/rsc";
|
2025-02-20 09:58:49 +00:00
|
|
|
import { Skeleton } from "@/components/ui/skeleton";
|
|
|
|
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
|
|
|
|
|
|
|
interface ProblemDescriptionProps {
|
|
|
|
mdxSource: string;
|
|
|
|
}
|
|
|
|
|
2025-02-20 10:46:20 +00:00
|
|
|
export async function ProblemDescription({ mdxSource }: ProblemDescriptionProps) {
|
|
|
|
try {
|
|
|
|
const { content } = await compileMDX({
|
|
|
|
source: mdxSource,
|
|
|
|
options: {
|
|
|
|
mdxOptions: {
|
|
|
|
remarkPlugins: [remarkGfm],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
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" />;
|
|
|
|
}
|
2025-02-20 09:58:49 +00:00
|
|
|
}
|