File tree Expand file tree Collapse file tree 3 files changed +34
-21
lines changed Expand file tree Collapse file tree 3 files changed +34
-21
lines changed Original file line number Diff line number Diff line change 88 - ' .github/workflows/**'
99
1010jobs :
11- validate- mdx :
11+ mdx-validation :
1212 runs-on : ubuntu-latest
1313 steps :
1414 - name : Checkout repo
@@ -21,27 +21,10 @@ jobs:
2121 cache : ' npm'
2222
2323 - name : MDX validation dependencies
24- run : npm install --save-dev @mdx-js/mdx @mdx-js/loader
24+ run : npm install --save-dev @mdx-js/mdx @mdx-js/loader glob
2525
2626 - name : Validate MDX files
27- run : |
28- # Find and validate all MDX files in the docs directory
29- find docs -name "*.mdx" -type f | while read file; do
30- echo "Validating: $file"
31- node -e "
32- const fs = require('fs');
33- const { compile } = require('@mdx-js/mdx');
34-
35- try {
36- const content = fs.readFileSync('$file', 'utf8');
37- compile(content, { jsx: true });
38- console.log('✅ $file - Valid MDX');
39- } catch (error) {
40- console.error('❌ $file - MDX Error:', error.message);
41- process.exit(1);
42- }
43- "
44- done
27+ run : node scripts/validate-mdx.js
4528
4629 - name : Check for broken links
4730 run : |
Original file line number Diff line number Diff line change 11{
2+ "type" : " module" ,
23 "devDependencies" : {
34 "@mdx-js/loader" : " ^3.1.0" ,
4- "@mdx-js/mdx" : " ^3.1.0"
5+ "@mdx-js/mdx" : " ^3.1.0" ,
6+ "glob" : " ^10.3.10"
57 }
68}
Original file line number Diff line number Diff line change 1+ import fs from 'fs' ;
2+ import { compile } from '@mdx-js/mdx' ;
3+ import { glob } from 'glob' ;
4+
5+ async function validateMDX ( ) {
6+ try {
7+ const mdxFiles = await glob ( 'docs/**/*.mdx' ) ;
8+
9+ for ( const file of mdxFiles ) {
10+ console . log ( `Validating: ${ file } ` ) ;
11+ try {
12+ const content = fs . readFileSync ( file , 'utf8' ) ;
13+ await compile ( content , { jsx : true } ) ;
14+ console . log ( `✅ ${ file } - Valid MDX` ) ;
15+ } catch ( error ) {
16+ console . error ( `❌ ${ file } - MDX Error:` , error . message ) ;
17+ process . exit ( 1 ) ;
18+ }
19+ }
20+
21+ console . log ( `\n🎉 All ${ mdxFiles . length } MDX files are valid!` ) ;
22+ } catch ( error ) {
23+ console . error ( '❌ Validation failed:' , error . message ) ;
24+ process . exit ( 1 ) ;
25+ }
26+ }
27+
28+ validateMDX ( ) ;
You can’t perform that action at this time.
0 commit comments