@@ -120,7 +120,12 @@ function combineSitemaps() {
120
120
121
121
// Collect URLs from each repository's sitemap
122
122
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
+
124
129
if ( fs . existsSync ( sitemapPath ) ) {
125
130
try {
126
131
const sitemapContent = fs . readFileSync ( sitemapPath , 'utf8' ) ;
@@ -145,22 +150,50 @@ function combineSitemaps() {
145
150
const normalizedPath = urlPath . replace ( / ^ \/ / , '' ) ;
146
151
const normalizedRepoName = repo . name . replace ( / ^ \/ / , '' ) . replace ( / \/ $ / , '' ) ;
147
152
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 } ` ;
151
170
} else {
152
- finalUrl = `${ siteUrl } /${ normalizedRepoName } /${ normalizedPath } ` ;
171
+ finalUrl = `${ siteUrl } /${ targetFolderName } /${ normalizedPath } ` ;
153
172
}
154
173
} else {
155
174
// For relative URLs, normalize paths
156
175
const normalizedUrl = url . replace ( / ^ \/ / , '' ) ;
157
176
const normalizedRepoName = repo . name . replace ( / ^ \/ / , '' ) . replace ( / \/ $ / , '' ) ;
158
177
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 } ` ;
162
195
} else {
163
- finalUrl = `${ siteUrl } /${ normalizedRepoName } /${ normalizedUrl } ` ;
196
+ finalUrl = `${ siteUrl } /${ targetFolderName } /${ normalizedUrl } ` ;
164
197
}
165
198
}
166
199
@@ -186,7 +219,7 @@ function combineSitemaps() {
186
219
console . warn ( `Warning: Could not process sitemap for ${ repo . name } : ${ error . message } ` ) ;
187
220
}
188
221
} else {
189
- console . warn ( `Warning: No sitemap found for ${ repo . name } ` ) ;
222
+ console . warn ( `Warning: No sitemap found for ${ repo . name } at ${ sitemapPath } ` ) ;
190
223
}
191
224
}
192
225
@@ -365,7 +398,9 @@ async function buildDocs() {
365
398
// Copy docs to the main docs directory if they exist
366
399
const docsDir = path . join ( process . cwd ( ) , 'docs' ) ;
367
400
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 ) ;
369
404
console . log ( `Copying docs from ${ docsDir } to ${ targetDir } ` ) ;
370
405
ensureDir ( targetDir ) ;
371
406
copyDirContents ( docsDir , targetDir ) ;
0 commit comments