MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / rehypeAddMDXExports

Function rehypeAddMDXExports

apps/baseai.dev/src/mdx/rehype.ts:72–102  ·  view source on GitHub ↗
(getExports: any)

Source from the content-addressed store, hash-verified

70}
71
72export 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
104export function getSections(node: any) {
105 let sections: any[] = [];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected