Skip to content

Commit 2a0fe82

Browse files
Copilotnixel2007
andcommitted
Fix edit link path calculation to use filePath instead of relativePath
Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
1 parent 97afa35 commit 2a0fe82

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

.vitepress/config.mts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,29 +171,31 @@ export default defineConfig({
171171
text: 'Редактировать страницу',
172172
pattern: ( pageData ) => {
173173

174-
const relativePath = pageData.relativePath
174+
const filePath = pageData.filePath
175175
const organization = pageData.params?.organization;
176176
const repository = pageData.params?.repository;
177177

178178
// If we have repository info from params, use it directly
179179
if (organization && repository) {
180-
if (relativePath.startsWith('api/')) {
180+
if (filePath.startsWith('api/')) {
181181
// For API paths, remove 'api/' and repository name from path
182-
const [_, repoSegment, ...rest] = relativePath.split('/')
182+
const [_, repoSegment, ...rest] = filePath.split('/')
183183
const restPath = rest.join('/')
184184
return `https://github.com/${organization}/${repository}/edit/master/docs/api/${restPath}`;
185185
}
186186

187187
// For product pages - determine path based on repository type
188-
if (repository === 'autumn') {
189-
// This is autumn documentation at root level - use entire relativePath
190-
const restPath = relativePath
191-
return `https://github.com/${organization}/${repository}/edit/master/docs/product/${restPath}`;
192-
} else {
193-
// This is other repository documentation - path after first segment (repository name)
194-
const [_, ...rest] = relativePath.split('/')
195-
const restPath = rest.join('/')
196-
return `https://github.com/${organization}/${repository}/edit/master/docs/product/${restPath}`;
188+
if (filePath.startsWith('products/')) {
189+
if (repository === 'autumn') {
190+
// For autumn documentation, use the relativePath since it's rewritten to remove products/autumn
191+
const restPath = pageData.relativePath
192+
return `https://github.com/${organization}/${repository}/edit/master/docs/product/${restPath}`;
193+
} else {
194+
// For other repository documentation - path after repository segment
195+
const [_, repoSegment, ...rest] = filePath.split('/')
196+
const restPath = rest.join('/')
197+
return `https://github.com/${organization}/${repository}/edit/master/docs/product/${restPath}`;
198+
}
197199
}
198200
}
199201

0 commit comments

Comments
 (0)