import visit from 'unist-util-visit' import type { Root } from 'mdast' export function FileTextMdxPlugin() { return transformer function transformer(tree: Root, file: any) { const addImports: string[] = [] visit(tree, 'jsx', (child: any, index, parent) => { const regexp = /` } else { const basicRegexp = /: ${child.value}. Correct Syntax: ` ) } } }) tree.children.unshift( ...addImports.map((importStr) => { return { type: 'import', value: importStr, } as any }) ) } }