jonbio/components/MDXComponents.js

21 lines
476 B
JavaScript
Raw Normal View History

2021-05-26 00:11:20 +08:00
import { MDXRemote } from 'next-mdx-remote'
2021-01-09 17:50:45 +08:00
import Image from 'next/image'
import CustomLink from './Link'
2021-05-20 23:57:13 +08:00
import Pre from './Pre'
2021-01-09 17:50:45 +08:00
2021-05-26 00:11:20 +08:00
export const MDXComponents = {
2021-01-09 17:50:45 +08:00
Image,
a: CustomLink,
2021-05-20 23:57:13 +08:00
pre: Pre,
2021-01-09 17:50:45 +08:00
}
2021-05-26 00:11:20 +08:00
export const MDXLayoutRenderer = ({ layout, mdxSource, ...rest }) => {
const LayoutComponent = require(`../layouts/${layout}`).default
return (
<LayoutComponent {...rest}>
<MDXRemote {...mdxSource} components={MDXComponents} />
</LayoutComponent>
)
}