-
Notifications
You must be signed in to change notification settings - Fork 5
/
mdx-components.tsx
47 lines (42 loc) · 1.14 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
import type { MDXComponents } from "mdx/types";
function CustomH1({
children,
}: React.HTMLAttributes<HTMLHeadElement>): JSX.Element {
return <h1 className="text-center">{children}</h1>;
}
function CustomP({
children,
}: React.HTMLAttributes<HTMLParagraphElement>): JSX.Element {
return <p className="text-justify">{children}</p>;
}
function CustomLi({
children,
}: React.HTMLAttributes<HTMLLIElement>): JSX.Element {
return <li className="text-justify">{children}</li>;
}
function CustomA({
children,
...props
}: React.AnchorHTMLAttributes<HTMLAnchorElement>): JSX.Element {
return (
<a className="text-justify hover:text-blue-700" {...props}>
{children}
</a>
);
}
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
h1: CustomH1,
p: CustomP,
li: CustomLi,
a: CustomA,
wrapper: ({ children }) => (
<div className="relative flex flex-1 flex-col overflow-hidden bg-gray-50 py-8 lg:py-12">
<article className="prose prose-slate mx-auto px-4 lg:prose-lg md:mt-8 md:px-0">
{children}
</article>
</div>
),
...components,
};
}