From 28ca45e4717a313e1b6c932738acf6551194b44a Mon Sep 17 00:00:00 2001 From: sarahschwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Wed, 17 Apr 2024 12:56:55 -0600 Subject: [PATCH] fix --- src/lib/code-import.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/code-import.ts b/src/lib/code-import.ts index 4c726d1..943d522 100644 --- a/src/lib/code-import.ts +++ b/src/lib/code-import.ts @@ -9,6 +9,7 @@ import * as prettier from 'prettier'; import type { Root } from 'remark-gfm'; import { visit } from 'unist-util-visit'; import type { Parent } from 'unist-util-visit'; +import { TESTNET_ENDPOINT } from '../constants'; const ROOT_DIR = path.resolve(__dirname, '../../../../../../../'); @@ -103,10 +104,15 @@ export function codeImport(options: Options = { filepath: '' }) { visit(tree, 'mdxJsxFlowElement', (node: any, idx, parent) => { if (node.name === 'CodeImport') { - nodes.push([node as any, idx, parent as Parent]); + nodes.push([node as any, idx!, parent as Parent]); } }); + visit(tree, '', (node: any, _idx, _parent) => { + if(node.type === 'code' && node.value.includes("TESTNET_ENDPOINT")) + node.value = node.value.replaceAll("TESTNET_ENDPOINT", `'${TESTNET_ENDPOINT}'`); + }); + nodes.forEach(([node]) => { const attr = node.attributes; let content = '';