Skip to content

Commit

Permalink
detect mdx2 errors and provide guidance to fix them
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Feb 3, 2023
1 parent 4ae75c0 commit 1785b13
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion code/lib/core-server/src/utils/StoryIndexGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path';
import chalk from 'chalk';
import fs from 'fs-extra';
import glob from 'globby';
import slash from 'slash';
Expand Down Expand Up @@ -369,7 +370,14 @@ export class StoryIndexGenerator {
};
return docsEntry;
} catch (err) {
logger.warn(`🚨 Extraction error on ${relativePath}: ${err}`);
logger.warn(`🚨 Extraction error on ${chalk.blue(relativePath)}: ${err}`);
if (err.source?.match(/mdast-util-mdx-jsx/g)) {
logger.warn(
`💡 This seems to be an MDX2 syntax error. Please refer to the following resource for assistance on how to fix this: ${chalk.yellow(
'http://link-to-resource/here'
)}`
);
}
throw err;
}
}
Expand Down

0 comments on commit 1785b13

Please sign in to comment.