@@ -14,6 +14,10 @@ function toSlug(name) {
1414 . replace ( / ^ - + | - $ / g, '' )
1515}
1616
17+ function stripH1 ( content ) {
18+ return content . replace ( / ^ # \s + .* \n ? / , '' ) . trim ( )
19+ }
20+
1721function getChangelog ( folder ) {
1822 const changelogPath = path . join ( docsModulesDir , folder , 'changelog.md' )
1923 if ( fs . existsSync ( changelogPath ) ) {
@@ -26,6 +30,18 @@ function getChangelog(folder) {
2630 return ''
2731}
2832
33+ function getAbout ( folder ) {
34+ const aboutPath = path . join ( docsModulesDir , folder , 'index.md' )
35+ if ( fs . existsSync ( aboutPath ) ) {
36+ try {
37+ return fs . readFileSync ( aboutPath , 'utf8' )
38+ } catch ( err ) {
39+ console . error ( `Failed to read about for ${ folder } :` , err )
40+ }
41+ }
42+ return ''
43+ }
44+
2945function main ( ) {
3046 if ( ! fs . existsSync ( modulesJsonPath ) ) {
3147 console . error ( 'modules.json not found, skipping modules.md generation.' )
@@ -80,20 +96,19 @@ function main() {
8096 const description = mod . description || 'No description available.'
8197 const features = mod . features || [ ]
8298 const download = mod . download || '#'
83- const sourceUrl = mod . source || ''
84-
85- // Extract folder from source URL: ../modules/{folder}/index.md
86- let folder = ''
87- const match = sourceUrl . match ( / \/ m o d u l e s \/ ( [ ^ / ] + ) \/ / )
88- if ( match ) {
89- folder = match [ 1 ]
90- }
99+ const folder = mod . folder || ''
100+ const slug = toSlug ( name )
91101
102+ const about = folder ? getAbout ( folder ) : ''
92103 const changelog = folder ? getChangelog ( folder ) : ''
93104
94- markdown += `<details>\n<summary>${ name } </summary>\n\n`
95- markdown += `- **Name**: ${ name } \n`
96- markdown += `- **Description**: ${ description } \n`
105+ markdown += `<details id="${ slug } ">\n<summary>${ name } </summary>\n\n`
106+
107+ if ( about ) {
108+ markdown += `### About\n\n${ stripH1 ( about ) } \n\n`
109+ } else {
110+ markdown += `- **Description**: ${ description } \n`
111+ }
97112
98113 if ( features . length > 0 ) {
99114 markdown += `- **Main Features**:\n`
@@ -106,8 +121,6 @@ function main() {
106121 markdown += `- <details><summary>Changelog</summary>\n\n`
107122 markdown += `${ changelog } \n\n`
108123 markdown += `</details>\n`
109- } else {
110- markdown += `- **Changelog**: Not available\n`
111124 }
112125
113126 markdown += `- [Download Button](${ download } )\n\n`
@@ -120,17 +133,9 @@ function main() {
120133 fs . writeFileSync ( modulesMdPath , markdown )
121134 console . log ( `Generated modules.md at ${ modulesMdPath } ` )
122135
123- // Write modules/index.md
124- let indexMarkdown = '# Modules\n\n'
125- if ( modules . length === 0 ) {
126- indexMarkdown += 'No module data available. Please check back later.\n'
127- } else {
128- modules . forEach ( mod => {
129- indexMarkdown += `- [${ mod . name || 'Unknown' } ](${ mod . source || '' } )\n`
130- } )
131- }
136+ // Write modules/index.md (Same content as modules.md now)
132137 fs . mkdirSync ( path . dirname ( modulesIndexMdPath ) , { recursive : true } )
133- fs . writeFileSync ( modulesIndexMdPath , indexMarkdown )
138+ fs . writeFileSync ( modulesIndexMdPath , markdown )
134139 console . log ( `Generated modules/index.md at ${ modulesIndexMdPath } ` )
135140}
136141
0 commit comments