Skip to content

Commit

Permalink
chore: fixing build error (#523)
Browse files Browse the repository at this point in the history
  • Loading branch information
petertonysmith94 authored Dec 5, 2024
1 parent 6dc982c commit b28447d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib/plugins/mdbook-example-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit b28447d

Please sign in to comment.