-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
MDXProvider.jsx
31 lines (29 loc) · 838 Bytes
/
MDXProvider.jsx
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
import React from 'react'
import { MDXProvider } from '@mdx-js/react'
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'
import okaidia from 'react-syntax-highlighter/dist/cjs/styles/prism/okaidia'
import SlidePage from '../layouts/SlidePage'
import Cover from './Cover'
import SpeakerNotes from './SpeakerNotes'
const mdComponents = {
h1: (props) => <h1 {...props} />,
pre: (props) => props.children,
code: (props) => {
const { className } = props
const language = className.replace('language-', '')
return (
<SyntaxHighlighter
className={className}
language={language}
style={okaidia}
{...props}
/>
)
},
Cover,
SlidePage,
SpeakerNotes,
}
export default ({ children }) => (
<MDXProvider components={mdComponents}>{children}</MDXProvider>
)