From b28447d7b15a3d488ae43c66bee47147f372c3eb Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 5 Dec 2024 22:29:46 +0000 Subject: [PATCH] chore: fixing build error (#523) --- src/lib/plugins/mdbook-example-import.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/plugins/mdbook-example-import.ts b/src/lib/plugins/mdbook-example-import.ts index 7f3f7b64c..ddf1b6684 100644 --- a/src/lib/plugins/mdbook-example-import.ts +++ b/src/lib/plugins/mdbook-example-import.ts @@ -90,8 +90,7 @@ export function handleExampleImports( if (paths.length > 1) exampleName = filePath.split(':').pop(); } else if (node.type === 'text') { // handle ts-sdk docs example format - const relativePath = dirname.replace('docs/fuels-ts/', '') - filePath = filePath.replace('<<< @./', `${relativePath}/`).replace(/<<< @\/?/, ''); + filePath = filePath.replace(/<<< @\/?/, ''); const pathData = filePath.split('{'); filePath = pathData[0]; @@ -132,6 +131,13 @@ export function handleExampleImports( ) .replace('fuels-ts/docs', 'fuels-ts/apps/docs'); } + + // If the example snippet is a relative path + // Then we can just join up the current dir path with the relative snippet path + if (filePath.startsWith('./')) { + fileAbsPath = path.join(dirname, filePath) + } + const fileContent = fs.readFileSync(fileAbsPath, 'utf8'); const cachedFile = getFilesOnCache(fileAbsPath);