Skip to content

Commit 173e88c

Browse files
Copilotnixel2007
andcommitted
Fix editLink organization issue for products from external repos
Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
1 parent 503cdf5 commit 173e88c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

.vitepress/config.mts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default defineConfig({
2525
return {
2626
params: {
2727
organization: repoData?.organization,
28+
repository: repoData?.repository,
2829
}
2930
}
3031

@@ -156,8 +157,23 @@ export default defineConfig({
156157

157158
const relativePath = pageData.relativePath
158159
const organization = pageData.params?.organization;
160+
const repository = pageData.params?.repository;
161+
162+
// If we have repository info from params, use it directly
163+
if (organization && repository) {
164+
const [_, ...rest] = relativePath.split('/')
165+
const restPath = rest.join('/')
166+
167+
if (relativePath.startsWith('api/')) {
168+
return `https://github.com/${organization}/${repository}/edit/master/docs/api/${restPath}`
169+
}
170+
171+
if (relativePath.startsWith('products/')) {
172+
return `https://github.com/${organization}/${repository}/edit/master/docs/product/${restPath}`
173+
}
174+
}
159175

160-
// Common calculation for repo extraction from relativePath
176+
// Fallback to old logic for paths that don't have repo info
161177
const [_, repoName, ...rest] = relativePath.split('/')
162178
const repoNamePath = repoName?.replace(/\d+-/g, '') || ''
163179
const restPath = rest.join('/')

0 commit comments

Comments
 (0)