@@ -627,6 +627,18 @@ function generateSitemap() {
627627 fs . writeFileSync ( path . join ( distDir , 'sitemap.xml' ) , xml ) ;
628628}
629629
630+ function getDescriptionFromMarkdown ( sourcePath ) {
631+ try {
632+ const currentDir = process . cwd ( ) ;
633+ const fullPath = path . join ( currentDir , 'src' , sourcePath ) ;
634+ const fileContent = fs . readFileSync ( fullPath , 'utf-8' ) ;
635+ const { frontMatter } = parseFrontMatter ( fileContent ) ;
636+ return frontMatter . description || '' ;
637+ } catch ( error ) {
638+ return '' ;
639+ }
640+ }
641+
630642function generateLLMs ( ) {
631643 let content = '# Puter.js Documentation\n\n' ;
632644 content += 'Build serverless applications with cloud storage, databases, and AI using Puter.js.\n\n' ;
@@ -637,14 +649,24 @@ function generateLLMs() {
637649 content += `## ${ sectionTitle } \n\n` ;
638650
639651 if ( section . path ) {
640- content += `- [${ sectionTitle } ](${ site } ${ section . path } /index.md)\n` ;
652+ const description = section . source ? getDescriptionFromMarkdown ( section . source ) : '' ;
653+ content += `- [${ sectionTitle } ](${ site } ${ section . path } /index.md)` ;
654+ if ( description ) {
655+ content += `: ${ description } ` ;
656+ }
657+ content += '\n' ;
641658 }
642659
643660 if ( section . children && Array . isArray ( section . children ) ) {
644661 section . children . forEach ( ( child ) => {
645662 if ( child . path ) {
646663 const childTitle = child . title_tag ?? child . title ;
647- content += `- [${ childTitle } ](${ site } ${ child . path } /index.md)\n` ;
664+ const description = child . source ? getDescriptionFromMarkdown ( child . source ) : '' ;
665+ content += `- [${ childTitle } ](${ site } ${ child . path } /index.md)` ;
666+ if ( description ) {
667+ content += `: ${ description } ` ;
668+ }
669+ content += '\n' ;
648670 }
649671 } ) ;
650672 }
0 commit comments