@@ -120,7 +120,12 @@ function combineSitemaps() {
120120
121121 // Collect URLs from each repository's sitemap
122122 for ( const repo of REPOS ) {
123- const sitemapPath = path . join ( 'docs' , repo . name , 'sitemap.xml' ) ;
123+ // Get the actual target folder name (editor-api -> editor)
124+ const targetFolderName = repo . name === 'editor-api' ? 'editor' : repo . name ;
125+
126+ // Look for the sitemap in the target folder, not necessarily the repo name folder
127+ const sitemapPath = path . join ( 'docs' , targetFolderName , 'sitemap.xml' ) ;
128+
124129 if ( fs . existsSync ( sitemapPath ) ) {
125130 try {
126131 const sitemapContent = fs . readFileSync ( sitemapPath , 'utf8' ) ;
@@ -145,22 +150,50 @@ function combineSitemaps() {
145150 const normalizedPath = urlPath . replace ( / ^ \/ / , '' ) ;
146151 const normalizedRepoName = repo . name . replace ( / ^ \/ / , '' ) . replace ( / \/ $ / , '' ) ;
147152
148- // Check if the path already includes the repo name to avoid duplication
149- if ( normalizedPath . startsWith ( `${ normalizedRepoName } /` ) ) {
150- finalUrl = `${ siteUrl } ${ urlPath } ` ;
153+ // Special handling for engine-v1 repository
154+ if ( repo . name === 'engine-v1' && normalizedPath . startsWith ( 'engine/' ) ) {
155+ // For engine-v1, remove the 'engine/' prefix from paths
156+ const pathWithoutEngine = normalizedPath . replace ( / ^ e n g i n e \/ / , '' ) ;
157+ finalUrl = `${ siteUrl } /${ targetFolderName } /${ pathWithoutEngine } ` ;
158+ }
159+ // Special handling for editor-api repository
160+ else if ( repo . name === 'editor-api' && normalizedPath . startsWith ( 'editor/' ) ) {
161+ // For editor-api, remove the 'editor/' prefix from paths
162+ const pathWithoutEditor = normalizedPath . replace ( / ^ e d i t o r \/ / , '' ) ;
163+ finalUrl = `${ siteUrl } /${ targetFolderName } /${ pathWithoutEditor } ` ;
164+ }
165+ // Regular handling for other repositories
166+ else if ( normalizedPath . startsWith ( `${ normalizedRepoName } /` ) ) {
167+ // Replace repository name in path with target folder name
168+ const adjustedPath = urlPath . replace ( normalizedRepoName , targetFolderName ) ;
169+ finalUrl = `${ siteUrl } ${ adjustedPath } ` ;
151170 } else {
152- finalUrl = `${ siteUrl } /${ normalizedRepoName } /${ normalizedPath } ` ;
171+ finalUrl = `${ siteUrl } /${ targetFolderName } /${ normalizedPath } ` ;
153172 }
154173 } else {
155174 // For relative URLs, normalize paths
156175 const normalizedUrl = url . replace ( / ^ \/ / , '' ) ;
157176 const normalizedRepoName = repo . name . replace ( / ^ \/ / , '' ) . replace ( / \/ $ / , '' ) ;
158177
159- // Check if the URL already starts with the repo name
160- if ( normalizedUrl . startsWith ( `${ normalizedRepoName } /` ) ) {
161- finalUrl = `${ siteUrl } /${ normalizedUrl } ` ;
178+ // Special handling for engine-v1 repository
179+ if ( repo . name === 'engine-v1' && normalizedUrl . startsWith ( 'engine/' ) ) {
180+ // For engine-v1, remove the 'engine/' prefix from paths
181+ const urlWithoutEngine = normalizedUrl . replace ( / ^ e n g i n e \/ / , '' ) ;
182+ finalUrl = `${ siteUrl } /${ targetFolderName } /${ urlWithoutEngine } ` ;
183+ }
184+ // Special handling for editor-api repository
185+ else if ( repo . name === 'editor-api' && normalizedUrl . startsWith ( 'editor/' ) ) {
186+ // For editor-api, remove the 'editor/' prefix from paths
187+ const pathWithoutEditor = normalizedUrl . replace ( / ^ e d i t o r \/ / , '' ) ;
188+ finalUrl = `${ siteUrl } /${ targetFolderName } /${ pathWithoutEditor } ` ;
189+ }
190+ // Regular handling for other repositories
191+ else if ( normalizedUrl . startsWith ( `${ normalizedRepoName } /` ) ) {
192+ // Replace repository name in path with target folder name
193+ const adjustedUrl = normalizedUrl . replace ( normalizedRepoName , targetFolderName ) ;
194+ finalUrl = `${ siteUrl } /${ adjustedUrl } ` ;
162195 } else {
163- finalUrl = `${ siteUrl } /${ normalizedRepoName } /${ normalizedUrl } ` ;
196+ finalUrl = `${ siteUrl } /${ targetFolderName } /${ normalizedUrl } ` ;
164197 }
165198 }
166199
@@ -186,7 +219,7 @@ function combineSitemaps() {
186219 console . warn ( `Warning: Could not process sitemap for ${ repo . name } : ${ error . message } ` ) ;
187220 }
188221 } else {
189- console . warn ( `Warning: No sitemap found for ${ repo . name } ` ) ;
222+ console . warn ( `Warning: No sitemap found for ${ repo . name } at ${ sitemapPath } ` ) ;
190223 }
191224 }
192225
@@ -365,7 +398,9 @@ async function buildDocs() {
365398 // Copy docs to the main docs directory if they exist
366399 const docsDir = path . join ( process . cwd ( ) , 'docs' ) ;
367400 if ( fs . existsSync ( docsDir ) ) {
368- const targetDir = path . join ( process . cwd ( ) , '..' , '..' , 'docs' , repo . name ) ;
401+ // Use "editor" folder for editor-api repository
402+ const targetFolderName = repo . name === 'editor-api' ? 'editor' : repo . name ;
403+ const targetDir = path . join ( process . cwd ( ) , '..' , '..' , 'docs' , targetFolderName ) ;
369404 console . log ( `Copying docs from ${ docsDir } to ${ targetDir } ` ) ;
370405 ensureDir ( targetDir ) ;
371406 copyDirContents ( docsDir , targetDir ) ;
0 commit comments