-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmdx-components.tsx
79 lines (70 loc) · 1.36 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import type { MDXComponents } from "mdx/types";
import type {
DetailedHTMLProps,
HTMLAttributes,
AnchorHTMLAttributes,
ReactNode,
} from "react";
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
...components,
h1: H1,
h2: H2,
h3: H3,
p: P,
a: A,
};
}
type HeadingProps = DetailedHTMLProps<
HTMLAttributes<HTMLHeadingElement>,
HTMLHeadingElement
> & {
children?: ReactNode;
};
function H1({ children, ...props }: HeadingProps) {
return (
<h1 {...props} className="text-5xl font-bold">
{children}
</h1>
);
}
function H2({ children, ...props }: HeadingProps) {
return (
<h2 {...props} className="text-4xl font-semibold">
{children}
</h2>
);
}
function H3({ children, ...props }: HeadingProps) {
return (
<h3 {...props} className="text-3xl font-medium">
{children}
</h3>
);
}
type PProps = DetailedHTMLProps<
HTMLAttributes<HTMLParagraphElement>,
HTMLParagraphElement
> & {
children?: ReactNode;
};
function P({ children, ...props }: PProps) {
return (
<p {...props} className="text-base leading-7">
{children}
</p>
);
}
type AProps = DetailedHTMLProps<
AnchorHTMLAttributes<HTMLAnchorElement>,
HTMLAnchorElement
> & {
children?: ReactNode;
};
function A({ children, ...props }: AProps) {
return (
<a {...props} className="text-blue-600 hover:underline">
{children}
</a>
);
}