Repository navigation
Expand file tree
/
Copy pathmdx-components.tsx
More file actions
158 lines (144 loc) · 3.78 KB
/
Copy pathmdx-components.tsx
File metadata and controls
158 lines (144 loc) · 3.78 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import type { MDXComponents } from "mdx/types";
import type { ComponentProps } from "react";
import defaultMdxComponents from "fumadocs-ui/mdx";
import { Accordion, Accordions } from "fumadocs-ui/components/accordion";
import { Callout } from "fumadocs-ui/components/callout";
import { Card, Cards } from "fumadocs-ui/components/card";
import { File, Files, Folder } from "fumadocs-ui/components/files";
import { Step, Steps } from "fumadocs-ui/components/steps";
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
import { TypeTable } from "fumadocs-ui/components/type-table";
import { CustomCodeBlock } from "@/components/code-block";
import { cn } from "@/lib/utils";
const FumadocsCodeBlockTabs = defaultMdxComponents.CodeBlockTabs;
function TypesetExcludedCodeBlock({
className,
...props
}: ComponentProps<"pre">) {
return (
<CustomCodeBlock
{...props}
className={cn("not-typeset mdx-code-block", className)}
/>
);
}
function BackgroundCodeBlockTabs({
className,
...props
}: ComponentProps<typeof FumadocsCodeBlockTabs>) {
return (
<FumadocsCodeBlockTabs
{...props}
className={cn("mdx-code-tabs", className)}
/>
);
}
function TypesetExcludedCallout({
className,
...props
}: ComponentProps<typeof Callout>) {
return (
<Callout
{...props}
className={cn("not-typeset mdx-callout", className)}
/>
);
}
function TypesetExcludedCard({
className,
...props
}: ComponentProps<typeof Card>) {
return (
<Card {...props} className={cn("not-typeset mdx-card", className)} />
);
}
function TypesetExcludedCards({
className,
...props
}: ComponentProps<typeof Cards>) {
return (
<Cards {...props} className={cn("not-typeset mdx-cards mt-4", className)} />
);
}
function BackgroundAccordions({
className,
...props
}: ComponentProps<typeof Accordions>) {
return (
<Accordions {...props} className={cn("mdx-accordions", className)} />
);
}
function BackgroundFiles({
className,
...props
}: ComponentProps<typeof Files>) {
return <Files {...props} className={cn("mdx-files", className)} />;
}
function BackgroundFile({
className,
...props
}: ComponentProps<typeof File>) {
return <File {...props} className={cn("mdx-file", className)} />;
}
function BackgroundFolder({
className,
...props
}: ComponentProps<typeof Folder>) {
return <Folder {...props} className={cn("mdx-folder", className)} />;
}
function BackgroundTabs({
className,
...props
}: ComponentProps<typeof Tabs>) {
return <Tabs {...props} className={cn("mdx-tabs", className)} />;
}
function TypesetExcludedTypeTable({
className,
...props
}: ComponentProps<typeof TypeTable>) {
return (
<TypeTable
{...props}
className={cn("not-typeset mdx-type-table", className)}
/>
);
}
function BackgroundTable({
className,
...props
}: ComponentProps<"table">) {
return (
<div className="mdx-table-wrap">
<table {...props} className={cn("mdx-table", className)} />
</div>
);
}
/**
* MDX components available in every documentation page.
*
* `defaultMdxComponents` already includes code blocks (with copy
* button), headings, tables, images, etc. Extend the map below to
* make more components available in your MDX content.
*/
export function getMDXComponents(components?: MDXComponents): MDXComponents {
return {
...defaultMdxComponents,
pre: TypesetExcludedCodeBlock,
table: BackgroundTable,
CodeBlockTabs: BackgroundCodeBlockTabs,
Accordion,
Accordions: BackgroundAccordions,
Callout: TypesetExcludedCallout,
Card: TypesetExcludedCard,
Cards: TypesetExcludedCards,
File: BackgroundFile,
Files: BackgroundFiles,
Folder: BackgroundFolder,
Step,
Steps,
Tab,
Tabs: BackgroundTabs,
TypeTable: TypesetExcludedTypeTable,
...components,
};
}