@@ -197,7 +197,10 @@ For the complete content with full formatting, code examples, and interactive el
197197
198198 return createResponse ( pageTitle , cleanContent , `/${ pathSegments . join ( '/' ) } ` ) ;
199199 } catch ( error ) {
200- console . error ( 'Error generating llms.txt:' , error ) ;
200+ // Log error to stderr in server environments, avoid console in production
201+ if ( process . env . NODE_ENV === 'development' ) {
202+ console . error ( 'Error generating llms.txt:' , error ) ;
203+ }
201204 return new NextResponse ( 'Internal server error' , { status : 500 } ) ;
202205 }
203206}
@@ -308,7 +311,7 @@ async function cleanupMarkdown(
308311 ) ;
309312}
310313
311- async function resolvePlatformIncludes (
314+ function resolvePlatformIncludes (
312315 content : string ,
313316 pathSegments : string [ ]
314317) : Promise < string > {
@@ -335,7 +338,8 @@ async function resolvePlatformIncludes(
335338 let result = content ;
336339 let match ;
337340
338- while ( ( match = includePattern . exec ( content ) ) !== null ) {
341+ // Fix assignment in while condition
342+ while ( ( match = includePattern . exec ( content ) ) ) {
339343 const includePath = match [ 1 ] ;
340344 const fullMatch = match [ 0 ] ;
341345
@@ -369,7 +373,10 @@ async function resolvePlatformIncludes(
369373 ) ;
370374 }
371375 } catch ( error ) {
372- console . error ( `Error loading include ${ includePath } :` , error ) ;
376+ // Log error conditionally to avoid console warnings in production
377+ if ( process . env . NODE_ENV === 'development' ) {
378+ console . error ( `Error loading include ${ includePath } :` , error ) ;
379+ }
373380 const sectionName = includePath . split ( '/' ) . pop ( ) || 'content' ;
374381 result = result . replace (
375382 fullMatch ,
@@ -378,5 +385,5 @@ async function resolvePlatformIncludes(
378385 }
379386 }
380387
381- return result ;
388+ return Promise . resolve ( result ) ;
382389}
0 commit comments