refactor(components): replace custom pre component with shared Pre component for MDX preview

This commit is contained in:
cfngc4594 2025-03-07 11:43:41 +08:00
parent f1b6e86123
commit 0159998234

View File

@ -7,12 +7,12 @@ import remarkMath from "remark-math";
import rehypeKatex from "rehype-katex"; import rehypeKatex from "rehype-katex";
// import rehypeSlug from "rehype-slug"; // import rehypeSlug from "rehype-slug";
import rehypePretty from "rehype-pretty-code"; import rehypePretty from "rehype-pretty-code";
import { Pre } from "@/components/content/pre";
import { Skeleton } from "@/components/ui/skeleton"; import { Skeleton } from "@/components/ui/skeleton";
import { serialize } from "next-mdx-remote/serialize"; import { serialize } from "next-mdx-remote/serialize";
import { useCallback, useEffect, useState } from "react"; import { useCallback, useEffect, useState } from "react";
import { CircleAlert, TriangleAlert } from "lucide-react"; import { CircleAlert, TriangleAlert } from "lucide-react";
import { useMonacoTheme } from "@/hooks/use-monaco-theme"; import { useMonacoTheme } from "@/hooks/use-monaco-theme";
import { CodeBlockWithCopy } from "./mdx/code-block-with-copy";
// import rehypeAutolinkHeadings from "rehype-autolink-headings"; // import rehypeAutolinkHeadings from "rehype-autolink-headings";
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
import { MDXRemote, MDXRemoteSerializeResult } from "next-mdx-remote"; import { MDXRemote, MDXRemoteSerializeResult } from "next-mdx-remote";
@ -31,7 +31,7 @@ export default function MdxPreview({ source }: MdxPreviewProps) {
// Define your custom components here // Define your custom components here
// For example: // For example:
// Test: ({ name }: { name: string }) => <p>Test Component: {name}</p>, // Test: ({ name }: { name: string }) => <p>Test Component: {name}</p>,
pre: CodeBlockWithCopy, pre: Pre,
}; };
const getMdxSource = useCallback(async () => { const getMdxSource = useCallback(async () => {