@@ -19,7 +19,16 @@ export default defineConfig({
19
19
const repositories = JSON . parse ( fs . readFileSync ( 'repositories.json' , 'utf-8' ) ) ;
20
20
const repositoriesMap : Map < string , RepoData > = new Map ( repositories . map ( ( repoData : RepoData ) => [ repoData . repository , repoData ] ) ) ;
21
21
22
- const repoName = pageData . relativePath . split ( '/' ) [ 1 ] ?. replace ( / \d + - / g, '' ) ;
22
+ // For products, after rewrite the repository name is in the first segment (index 0)
23
+ // For api, the repository name is in the second segment (index 1)
24
+ let repoName : string ;
25
+ if ( pageData . relativePath . startsWith ( 'api/' ) ) {
26
+ repoName = pageData . relativePath . split ( '/' ) [ 1 ] ?. replace ( / \d + - / g, '' ) || '' ;
27
+ } else {
28
+ // For products and other paths, repository name is in the first segment
29
+ repoName = pageData . relativePath . split ( '/' ) [ 0 ] ?. replace ( / \d + - / g, '' ) || '' ;
30
+ }
31
+
23
32
const repoData = repositoriesMap . get ( repoName ) ;
24
33
25
34
return {
@@ -165,11 +174,17 @@ export default defineConfig({
165
174
const restPath = rest . join ( '/' )
166
175
167
176
if ( relativePath . startsWith ( 'api/' ) ) {
168
- return `https://github.com/${ organization } /${ repository } /edit/master/docs/api/${ restPath } `
177
+ return `https://github.com/${ organization } /${ repository } /edit/master/docs/api/${ restPath } ` ;
169
178
}
170
179
171
- if ( relativePath . startsWith ( 'products/' ) ) {
172
- return `https://github.com/${ organization } /${ repository } /edit/master/docs/product/${ restPath } `
180
+ // For product pages, check if path starts with known product directory names
181
+ // or if we have repository info (indicating it's a product page)
182
+ const repoNames = [ 'autumn' , 'winow' , 'annotations' , 'extends' , 'autumn-cli' , 'autumn-collections' , 'autumn-logos' ] ;
183
+ const isProductPage = repoNames . some ( name => relativePath . startsWith ( name + '/' ) ) ||
184
+ relativePath . split ( '/' ) [ 0 ] === repository ;
185
+
186
+ if ( isProductPage ) {
187
+ return `https://github.com/${ organization } /${ repository } /edit/master/docs/product/${ restPath } ` ;
173
188
}
174
189
}
175
190
@@ -180,11 +195,11 @@ export default defineConfig({
180
195
const orgName = organization || 'autumn-library' ;
181
196
182
197
if ( relativePath . startsWith ( 'api/' ) ) {
183
- return `https://github.com/${ orgName } /${ repoNamePath } /edit/master/docs/api/${ restPath } `
198
+ return `https://github.com/${ orgName } /${ repoNamePath } /edit/master/docs/api/${ restPath } ` ;
184
199
}
185
200
186
201
if ( relativePath . startsWith ( 'products/' ) ) {
187
- return `https://github.com/${ orgName } /${ repoNamePath } /edit/master/docs/product/${ restPath } `
202
+ return `https://github.com/${ orgName } /${ repoNamePath } /edit/master/docs/product/${ restPath } ` ;
188
203
}
189
204
190
205
return ''
0 commit comments