compile

Function compile 

Source
pub fn compile(value: &str, options: &Options) -> Result<String, Message>
Expand description

Turn MDX into JavaScript.

§Examples

use mdxjs::compile;

assert_eq!(compile("# Hi!", &Default::default())?, "import { jsx as _jsx } from \"react/jsx-runtime\";\nfunction _createMdxContent(props) {\n    const _components = Object.assign({\n        h1: \"h1\"\n    }, props.components);\n    return _jsx(_components.h1, {\n        children: \"Hi!\"\n    });\n}\nfunction MDXContent(props = {}) {\n    const { wrapper: MDXLayout } = props.components || {};\n    return MDXLayout ? _jsx(MDXLayout, Object.assign({}, props, {\n        children: _jsx(_createMdxContent, props)\n    })) : _createMdxContent(props);\n}\nexport default MDXContent;\n");

§Errors

This project errors for many different reasons, such as syntax errors in the MDX format or misconfiguration.