-
Notifications
You must be signed in to change notification settings - Fork 378
/
mdx-components.tsx
65 lines (63 loc) · 1.8 KB
/
mdx-components.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import type { MDXComponents } from "mdx/types";
import { Accordion, Accordions } from "fumadocs-ui/components/accordion";
import { Step, Steps } from "fumadocs-ui/components/steps";
import { Callout } from "fumadocs-ui/components/callout";
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
import { Cards, Card } from "fumadocs-ui/components/card";
import { TypeTable } from "fumadocs-ui/components/type-table";
import defaultComponents from "fumadocs-ui/mdx";
import {
CodeBlock,
type CodeBlockProps,
Pre,
} from "fumadocs-ui/components/codeblock";
import type { ReactNode } from "react";
import { Popup, PopupContent, PopupTrigger } from "fumadocs-ui/twoslash/popup";
import YouTube from "@/components/youtube";
import Gallery from "@/components/gallery";
import { cn } from "./utils/cn";
import { BadgeCheck } from "lucide-react";
import dynamic from "next/dynamic";
const Mermaid = dynamic(() => import("@/components/mermaid"), {
ssr: false,
});
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
...defaultComponents,
BadgeCheck,
Popup,
PopupContent,
PopupTrigger,
pre: ({ title, className, icon, allowCopy, ...props }: CodeBlockProps) => (
<CodeBlock title={title} icon={icon} allowCopy={allowCopy}>
<Pre className={cn("max-h-[1200px]", className)} {...props} />
</CodeBlock>
),
Tabs,
Tab,
Cards,
Card,
Callout,
TypeTable,
Step,
Steps,
Accordion,
Accordions,
YouTube,
Gallery,
Mermaid,
InstallTabs: ({
items,
children,
}: {
items: string[];
children: ReactNode;
}) => (
<Tabs items={items} id="package-manager">
{children}
</Tabs>
),
blockquote: (props) => <Callout>{props.children}</Callout>,
...components,
};
}