(getExports: any)
| 70 | } |
| 71 | |
| 72 | export function rehypeAddMDXExports(getExports: any) { |
| 73 | return (tree: any) => { |
| 74 | let exports = Object.entries(getExports(tree)); |
| 75 | |
| 76 | for (let [name, value] of exports) { |
| 77 | for (let node of tree.children) { |
| 78 | if ( |
| 79 | node.type === 'mdxjsEsm' && |
| 80 | new RegExp(`export\\s+const\\s+${name}\\s*=`).test( |
| 81 | node.value |
| 82 | ) |
| 83 | ) { |
| 84 | return; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | let exportStr = `export const ${name} = ${value}`; |
| 89 | |
| 90 | tree.children.push({ |
| 91 | type: 'mdxjsEsm', |
| 92 | value: exportStr, |
| 93 | data: { |
| 94 | estree: acorn.parse(exportStr, { |
| 95 | sourceType: 'module', |
| 96 | ecmaVersion: 'latest' |
| 97 | }) |
| 98 | } |
| 99 | }); |
| 100 | } |
| 101 | }; |
| 102 | } |
| 103 | |
| 104 | export function getSections(node: any) { |
| 105 | let sections: any[] = []; |
nothing calls this directly
no outgoing calls
no test coverage detected