(source = '', filename = '')
| 172 | * @param {string} filename |
| 173 | */ |
| 174 | const _getMDXContent = async (source = '', filename = '') => { |
| 175 | // We create a VFile (Virtual File) to be able to access some contextual |
| 176 | // data post serialization (compilation) of the source Markdown into MDX |
| 177 | const sourceAsVirtualFile = new VFile(source); |
| 178 | |
| 179 | // Gets the file extension of the file, to determine which parser and plugins to use |
| 180 | const fileExtension = filename.endsWith('.mdx') ? 'mdx' : 'md'; |
| 181 | |
| 182 | // This compiles our MDX source (VFile) into a final MDX-parsed VFile |
| 183 | // that then is passed as a string to the MDXProvider which will run the MDX Code |
| 184 | return compile(sourceAsVirtualFile, fileExtension, mdxComponents); |
| 185 | }; |
| 186 | |
| 187 | // Creates a Cached Version of the MDX Compiler |
| 188 | const getMDXContent = cache(async (source, filename) => { |
no test coverage detected