astro/packages/markdown/remark/src/rehype-expressions.ts
2021-12-22 16:11:05 -05:00

12 lines
302 B
TypeScript

import { map } from 'unist-util-map';
export default function rehypeExpressions(): any {
return function (node: any): any {
return map(node, (child) => {
if (child.type === 'mdxTextExpression') {
return { type: 'text', value: `{${(child as any).value}}` };
}
return child;
});
};
}