Skip to content

Commit c824520

Browse files
Copilotnixel2007
andcommitted
Use filePath consistently for all repository detection instead of mixed approach
Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
1 parent 81275ef commit c824520

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

.vitepress/config.mts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ export default defineConfig({
1919
const repositories = JSON.parse(fs.readFileSync('repositories.json', 'utf-8'));
2020
const repositoriesMap: Map<string, RepoData> = new Map(repositories.map((repoData: RepoData) => [repoData.repository, repoData]));
2121

22-
let repoName: string;
22+
let repoName: string = '';
2323

24-
if (pageData.relativePath.startsWith('api/')) {
25-
// For API paths, repository name is in the second segment after rewrite
26-
repoName = pageData.relativePath.split('/')[1] || '';
27-
} else {
28-
// Use filePath to determine if this is autumn documentation
29-
// pageData.filePath contains the original path before rewrites
30-
if (pageData.filePath && pageData.filePath.includes('products/000-autumn')) {
31-
// This is autumn documentation at root level (after rewrite from products/000-autumn/)
32-
repoName = 'autumn';
33-
} else {
34-
// For other products, repository name is in the first segment after rewrite
35-
repoName = pageData.relativePath.split('/')[0] || '';
24+
// Use filePath for all variants to extract repository name
25+
if (pageData.filePath) {
26+
if (pageData.filePath.startsWith('api/')) {
27+
// For API paths: api/000-autumn/... or api/003-extends/...
28+
const pathSegments = pageData.filePath.split('/');
29+
const repoSegment = pathSegments[1] || '';
30+
repoName = repoSegment.replace(/^\d+-/, ''); // Remove number prefix
31+
} else if (pageData.filePath.startsWith('products/')) {
32+
// For product paths: products/000-autumn/... or products/003-extends/...
33+
const pathSegments = pageData.filePath.split('/');
34+
const repoSegment = pathSegments[1] || '';
35+
repoName = repoSegment.replace(/^\d+-/, ''); // Remove number prefix
3636
}
3737
}
3838

@@ -184,8 +184,8 @@ export default defineConfig({
184184
return `https://github.com/${organization}/${repository}/edit/master/docs/api/${restPath}`;
185185
}
186186

187-
// For product pages - use filePath to determine if it's autumn docs
188-
if (pageData.filePath && pageData.filePath.includes('products/000-autumn')) {
187+
// For product pages - determine path based on repository type
188+
if (repository === 'autumn') {
189189
// This is autumn documentation at root level - use entire relativePath
190190
const restPath = relativePath
191191
return `https://github.com/${organization}/${repository}/edit/master/docs/product/${restPath}`;

0 commit comments

Comments
 (0)