11import fs from "fs/promises" ;
2- const basePath = new URL (
3- "../../inputfiles/mdn/files/en-us/web/api/" ,
4- import . meta. url ,
5- ) ;
2+ const basePath = new URL ( "../../inputfiles/mdn/files/en-us/" , import . meta. url ) ;
3+ const inputPaths = [ "web/api/" , "webassembly/reference/javascript_interface/" ] ;
64
75function extractSummary ( markdown : string ) : string {
86 // Remove frontmatter (--- at the beginning)
@@ -75,6 +73,10 @@ const paths: Record<string, string[]> = {
7573 "web-api-interface" : [ ] ,
7674 "webgl-extension" : [ ] ,
7775 "webgl-extension-method" : [ "methods" , "method" ] ,
76+ "webassembly-interface" : [ ] ,
77+ "webassembly-instance-method" : [ "methods" , "method" ] ,
78+ "webassembly-instance-property" : [ "properties" , "property" ] ,
79+ "webassembly-static-method" : [ "methods" , "method" ] ,
7880} ;
7981
8082function generatePath ( content : string ) : string [ ] | undefined {
@@ -87,8 +89,11 @@ function extractSlug(content: string): string[] {
8789 const match = content . match ( / \n s l u g : ( .+ ) \n / ) ! ;
8890 const url = match [ 1 ] . split ( ":" ) . pop ( ) ! ;
8991 const normalized = url . endsWith ( "_static" ) ? url . slice ( 0 , - 7 ) : url ;
90- const parts = normalized . split ( "/" ) . slice ( 2 ) ; // skip `Web/API/...`
91- return parts ; // Keep only top-level and member name
92+ const parts = normalized . split ( "/" ) ;
93+ if ( parts [ 0 ] . toLowerCase ( ) === "web" ) {
94+ return parts . slice ( 2 ) ;
95+ }
96+ return parts . slice ( 3 ) ;
9297}
9398
9499function ensureLeaf ( obj : Record < string , any > , keys : string [ ] ) {
@@ -127,7 +132,11 @@ export async function generateDescriptions(): Promise<{
127132 }
128133
129134 const results : Record < string , any > = { } ;
130- const indexPaths = await walkDirectory ( basePath ) ;
135+ const indexPaths = await Promise . all (
136+ inputPaths . map (
137+ async ( path ) => await walkDirectory ( new URL ( path , basePath ) ) ,
138+ ) ,
139+ ) . then ( ( res ) => res . flat ( ) ) ;
131140
132141 await Promise . all (
133142 indexPaths . map ( async ( fileURL ) => {
0 commit comments