@@ -33,8 +33,11 @@ function generateLlmsTxt() {
3333 content += `## ${ category . label } \n\n` ;
3434 const files = getMarkdownFiles ( category . items ) ;
3535 for ( const file of files ) {
36- const filePath = path . join ( docsDir , `${ file } .md` ) ;
37- if ( fs . existsSync ( filePath ) ) {
36+ const mdPath = path . join ( docsDir , `${ file } .md` ) ;
37+ const mdxPath = path . join ( docsDir , `${ file } .mdx` ) ;
38+ const filePath = fs . existsSync ( mdPath ) ? mdPath : fs . existsSync ( mdxPath ) ? mdxPath : null ;
39+
40+ if ( filePath ) {
3841 const fileContent = fs . readFileSync ( filePath , 'utf-8' ) ;
3942 const match = fileContent . match ( / - - - \s * s i d e b a r _ l a b e l : \s * " ( .* ?) " \s * - - - / ) ;
4043 const title = match ? match [ 1 ] : path . basename ( file , '.md' ) ;
@@ -61,8 +64,12 @@ function generateLlmsFullTxt() {
6164 if ( match ) {
6265 const url = match [ 2 ] ;
6366 const relativeUrl = new URL ( url ) . pathname ;
64- const filePath = path . join ( __dirname , '..' , relativeUrl . substring ( 1 ) + '.md' ) ;
65- if ( fs . existsSync ( filePath ) ) {
67+ const docPath = path . join ( __dirname , '..' , relativeUrl . substring ( 1 ) ) ;
68+ const mdPath = docPath + '.md' ;
69+ const mdxPath = docPath + '.mdx' ;
70+ const filePath = fs . existsSync ( mdPath ) ? mdPath : fs . existsSync ( mdxPath ) ? mdxPath : null ;
71+
72+ if ( filePath ) {
6673 let fileContent = fs . readFileSync ( filePath , 'utf-8' ) ;
6774 fileContent = fileContent . replace ( / - - - [ \s \S ] * ?- - - / , '' ) . trim ( ) ;
6875 const relativePath = path . relative ( path . join ( __dirname , '..' ) , filePath ) ;
0 commit comments