async generate() { const config = await this.getConfig( ['.mdxrc', 'mdx.config.js', 'package.json'], {packageKey: 'mdx'} ) const compiled = await mdx(this.contents, config) const fullCode = ` import React from 'react'; import { MDXTag } from '@mdx-js/tag'; ${compiled} ` return [ { type: 'js', value: fullCode, sourceMap: undefined } ] }
module.exports = async function(content) { const callback = this.async() const options = Object.assign({}, getOptions(this), { filepath: this.resourcePath }) let result try { result = await mdx(content, options) } catch (err) { return callback(err) } const code = ` import React from 'react' import { MDXTag } from '@mdx-js/tag' ${result} ` return callback(null, code) }
const compile = (src, o = {}) => mdx(src, { mdPlugins: options.mdPlugins || [], hastPlugins: [...(options.hastPlugins || []), syncAstNodes(ast, options.filePath)], })