(getExports)
| 29 | } |
| 30 | |
| 31 | function rehypeAddMDXExports(getExports) { |
| 32 | return (tree) => { |
| 33 | let exports = Object.entries(getExports(tree)) |
| 34 | |
| 35 | for (let [name, value] of exports) { |
| 36 | for (let node of tree.children) { |
| 37 | if ( |
| 38 | node.type === 'mdxjsEsm' && |
| 39 | new RegExp(`export\\s+const\\s+${name}\\s*=`).test(node.value) |
| 40 | ) { |
| 41 | return |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | let exportStr = `export const ${name} = ${value}` |
| 46 | |
| 47 | tree.children.push({ |
| 48 | type: 'mdxjsEsm', |
| 49 | value: exportStr, |
| 50 | data: { |
| 51 | estree: acorn.parse(exportStr, { |
| 52 | sourceType: 'module', |
| 53 | ecmaVersion: 'latest', |
| 54 | }), |
| 55 | }, |
| 56 | }) |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | function getSections(node) { |
| 62 | let sections = [] |
nothing calls this directly
no outgoing calls
no test coverage detected