-
Notifications
You must be signed in to change notification settings - Fork 6
/
mdx-components.tsx
31 lines (28 loc) · 973 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
29
30
31
// THIS FILE ONLY ADD COMPONENTS TO MDX PAGES. THE BLOG POSTS COMPONENTS ARE IN THE `utils/Markdown` COMPONENT.
import type { MDXComponents } from 'mdx/types'
import ButtonLink from '@/design-system/inputs/ButtonLink'
import Title from '@/design-system/layout/Title'
import Image from 'next/image'
// This file is required to use MDX in `app` directory.
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
// Allows customizing built-in components, e.g. to add styling.
h1: Title,
ButtonLink: (props: any) => (
<div className="text-center">
<ButtonLink href={props.href}>{props.children}</ButtonLink>
</div>
),
img: (props: any) => (
<Image
sizes="100vw"
width={props.width ?? 900}
height={props.height ?? 500}
style={{ width: '100%', height: 'auto' }}
alt={props.alt as string}
{...(props as any)}
/>
),
...components,
}
}