mirror of
https://github.com/jxnblk/mdx-deck.git
synced 2024-12-01 21:42:08 +03:00
22 lines
539 B
JavaScript
22 lines
539 B
JavaScript
const { getOptions } = require('loader-utils')
|
|
const mdx = require('@mdx-js/mdx')
|
|
const mdxPlugin = require('@mdx-deck/mdx-plugin')
|
|
|
|
module.exports = async function(src) {
|
|
const callback = this.async()
|
|
const options = getOptions(this) || {}
|
|
options.remarkPlugins = [
|
|
...options.remarkPlugins,
|
|
...(options.mdPlugins || []),
|
|
]
|
|
options.remarkPlugins.push(mdxPlugin)
|
|
|
|
const result = mdx.sync(src, options)
|
|
|
|
const code = `/** @jsx mdx */
|
|
import { mdx } from '@mdx-js/react'
|
|
${result}`
|
|
|
|
return callback(null, code)
|
|
}
|