-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMDXComponents.tsx
46 lines (39 loc) · 1.05 KB
/
MDXComponents.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
import Link from 'next/link'
import Image from 'next/image'
import ImageWithTheme from './ImageWithTheme'
import ConsCard from './ConsCard'
import ProsCard from './ProsCard'
import Step from './Step'
const CustomLink = (props: any) => {
const href = props.href
const isInternalLink = href && (href.startsWith('/') || href.startsWith('#'))
if (isInternalLink) {
return (
<Link href={href}>
<a {...props}>{props.children}</a>
</Link>
)
}
return <a target="_blank" rel="noopener noreferrer" {...props} />
}
function RoundedImage(props: any) {
return <Image alt={props.alt} className="rounded-lg" {...props} />
}
function Callout(props: any) {
return (
<div className="flex rounded-lg bg-gray-200 p-4 dark:bg-gray-800">
<div className="mr-4 flex w-4 items-center">{props.emoji}</div>
<div className="callout w-full">{props.children}</div>
</div>
)
}
const MDXComponents = {
Image: RoundedImage,
ImageWithTheme,
a: CustomLink,
Callout,
ConsCard,
ProsCard,
Step,
}
export default MDXComponents