@@ -19,14 +19,23 @@ 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
- // 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
22
let repoName : string ;
23
+
25
24
if ( pageData . relativePath . startsWith ( 'api/' ) ) {
25
+ // For API paths, repository name is in the second segment after rewrite
26
26
repoName = pageData . relativePath . split ( '/' ) [ 1 ] ?. replace ( / \d + - / g, '' ) || '' ;
27
27
} else {
28
- // For products and other paths, repository name is in the first segment
29
- repoName = pageData . relativePath . split ( '/' ) [ 0 ] ?. replace ( / \d + - / g, '' ) || '' ;
28
+ // Check if this is a root-level autumn path (after rewrite from products/autumn/)
29
+ const firstSegment = pageData . relativePath . split ( '/' ) [ 0 ] ;
30
+ const autumnRootDirs = [ 'getting-started' , 'framework-elements' ] ;
31
+
32
+ if ( autumnRootDirs . includes ( firstSegment ) ) {
33
+ // This is autumn documentation at root level
34
+ repoName = 'autumn' ;
35
+ } else {
36
+ // For other products, repository name is in the first segment after rewrite
37
+ repoName = firstSegment ?. replace ( / \d + - / g, '' ) || '' ;
38
+ }
30
39
}
31
40
32
41
const repoData = repositoriesMap . get ( repoName ) ;
@@ -170,20 +179,26 @@ export default defineConfig({
170
179
171
180
// If we have repository info from params, use it directly
172
181
if ( organization && repository ) {
173
- const [ _ , ...rest ] = relativePath . split ( '/' )
174
- const restPath = rest . join ( '/' )
175
-
176
182
if ( relativePath . startsWith ( 'api/' ) ) {
183
+ // For API paths, remove 'api/' and repository name from path
184
+ const [ _ , repoSegment , ...rest ] = relativePath . split ( '/' )
185
+ const restPath = rest . join ( '/' )
177
186
return `https://github.com/${ organization } /${ repository } /edit/master/docs/api/${ restPath } ` ;
178
187
}
179
188
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 ;
189
+ // For product pages
190
+ const firstSegment = relativePath . split ( '/' ) [ 0 ] ;
191
+ const autumnRootDirs = [ 'getting-started' , 'framework-elements' ] ;
185
192
186
- if ( isProductPage ) {
193
+ if ( autumnRootDirs . includes ( firstSegment ) ) {
194
+ // This is autumn documentation at root level - path after first segment
195
+ const [ _ , ...rest ] = relativePath . split ( '/' )
196
+ const restPath = rest . join ( '/' )
197
+ return `https://github.com/${ organization } /${ repository } /edit/master/docs/product/${ restPath } ` ;
198
+ } else {
199
+ // This is other repository documentation - path after first segment (repository name)
200
+ const [ _ , ...rest ] = relativePath . split ( '/' )
201
+ const restPath = rest . join ( '/' )
187
202
return `https://github.com/${ organization } /${ repository } /edit/master/docs/product/${ restPath } ` ;
188
203
}
189
204
}
0 commit comments