-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmdx-components.tsx
28 lines (26 loc) · 932 Bytes
/
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
import type { MDXComponents } from "mdx/types";
import Button from "@/components/ui/Button";
import { HashIcon } from "@/components/ui/Icons";
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
// Allows customizing built-in components, e.g. to add styling.
h2: ({ children }) => (
<h2 id={children?.toString().toLowerCase()} className=" group/item">
<Button style="!p-2 mr-3 invisible group-hover/item:visible">
<HashIcon style="text-sm" />
</Button>
{children}
</h2>
),
h3: ({ children }) => (
<h3 id={children?.toString().toLowerCase()} className=" group/item">
<Button style="!p-2 mr-3 invisible group-hover/item:visible">
<HashIcon style="text-xs" />
</Button>
{children}
</h3>
),
hr: ({ children }) => <div className="docLine">{children}</div>,
...components,
};
}