From 5efdd92dc77bac1bd02a9f738253cf60d663d297 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Jun 2025 11:54:44 +0000 Subject: [PATCH 1/7] Initial plan for issue From 2e0559373ec7813ca53e063d2ae66e43189d7b2b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Jun 2025 11:58:25 +0000 Subject: [PATCH 2/7] Initial assessment: Understand the editLink issue with orgName from repositories.json Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com> --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index ca7bec2..0e15770 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "docs", + "name": "autumn-library.github.io", "lockfileVersion": 3, "requires": true, "packages": { From a6453c2ae83ccd0a15cd8811b90ac4b920373bc6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Jun 2025 12:02:18 +0000 Subject: [PATCH 3/7] Fix editLink to use correct orgName from repositories.json Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com> --- .vitepress/config.mts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.vitepress/config.mts b/.vitepress/config.mts index c7e38c7..a310e4c 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -20,7 +20,8 @@ export default defineConfig({ const repositoriesMap: Map = new Map(repositories.map((repoData: RepoData) => [repoData.repository, repoData])); const repoName = pageData.relativePath.split('/')[1]; - const repoData = repositoriesMap.get(repoName); + const cleanRepoName = repoName?.replace(/\d+-/g, ''); + const repoData = repositoriesMap.get(cleanRepoName); return { params: { @@ -155,9 +156,11 @@ export default defineConfig({ pattern: ( pageData ) => { const filePath = pageData.filePath + const relativePath = pageData.relativePath const organization = pageData.params?.organization; - const [_, repoName, ...rest] = filePath.split('/') + // Use relativePath to get the original repository name (before rewrites) + const [_, repoName, ...rest] = relativePath.split('/') const repoNamePath = repoName.replace(/\d+-/g, '') const restPath = rest.join('/') const orgName = organization || 'autumn-library'; From 63ccb0a637182488e5b54329e13bf674de0277d7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Jun 2025 12:25:23 +0000 Subject: [PATCH 4/7] Inline cleanRepoName variable as requested in code review Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com> --- .vitepress/config.mts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.vitepress/config.mts b/.vitepress/config.mts index a310e4c..84cff6b 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -20,8 +20,7 @@ export default defineConfig({ const repositoriesMap: Map = new Map(repositories.map((repoData: RepoData) => [repoData.repository, repoData])); const repoName = pageData.relativePath.split('/')[1]; - const cleanRepoName = repoName?.replace(/\d+-/g, ''); - const repoData = repositoriesMap.get(cleanRepoName); + const repoData = repositoriesMap.get(repoName?.replace(/\d+-/g, '')); return { params: { From 816719e8fadc399ade6663e1ba948208be7025f4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Jun 2025 12:31:24 +0000 Subject: [PATCH 5/7] Use filePath instead of relativePath for editLink pattern as requested Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com> --- .vitepress/config.mts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.vitepress/config.mts b/.vitepress/config.mts index 84cff6b..633d0f0 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -155,23 +155,20 @@ export default defineConfig({ pattern: ( pageData ) => { const filePath = pageData.filePath - const relativePath = pageData.relativePath const organization = pageData.params?.organization; - // Use relativePath to get the original repository name (before rewrites) - const [_, repoName, ...rest] = relativePath.split('/') - const repoNamePath = repoName.replace(/\d+-/g, '') - const restPath = rest.join('/') - const orgName = organization || 'autumn-library'; - if (filePath.startsWith('api/')) { - return `https://github.com/${orgName}/${repoNamePath}/edit/master/docs/api/${restPath}` + const [_, repoName, ...rest] = filePath.split('/') + const restPath = rest.join('/') + const orgName = organization || 'autumn-library'; + return `https://github.com/${orgName}/${repoName}/edit/master/docs/api/${restPath}` } - if (filePath.startsWith('products/')) { - return `https://github.com/${orgName}/${repoNamePath}/edit/master/docs/product/${restPath}` - } - return '' + // For products (after rewrites, products/ prefix is removed) + const [repoName, ...rest] = filePath.split('/') + const restPath = rest.join('/') + const orgName = organization || 'autumn-library'; + return `https://github.com/${orgName}/${repoName}/edit/master/docs/product/${restPath}` } }, From 718e71702f509068acdb78c69457517a3cd92be5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Jun 2025 12:36:54 +0000 Subject: [PATCH 6/7] Use relativePath for path checks and restore common repo extraction as requested Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com> --- .vitepress/config.mts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.vitepress/config.mts b/.vitepress/config.mts index 633d0f0..f84ee47 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -154,21 +154,21 @@ export default defineConfig({ text: 'Редактировать страницу', pattern: ( pageData ) => { - const filePath = pageData.filePath + const relativePath = pageData.relativePath const organization = pageData.params?.organization; - if (filePath.startsWith('api/')) { - const [_, repoName, ...rest] = filePath.split('/') - const restPath = rest.join('/') - const orgName = organization || 'autumn-library'; - return `https://github.com/${orgName}/${repoName}/edit/master/docs/api/${restPath}` - } - - // For products (after rewrites, products/ prefix is removed) - const [repoName, ...rest] = filePath.split('/') + // Common calculation for repo extraction from relativePath + const [_, repoName, ...rest] = relativePath.split('/') + const repoNamePath = repoName.replace(/\d+-/g, '') const restPath = rest.join('/') const orgName = organization || 'autumn-library'; - return `https://github.com/${orgName}/${repoName}/edit/master/docs/product/${restPath}` + + if (relativePath.startsWith('api/')) { + return `https://github.com/${orgName}/${repoNamePath}/edit/master/docs/api/${restPath}` + } + + // For products + return `https://github.com/${orgName}/${repoNamePath}/edit/master/docs/product/${restPath}` } }, From f9a40a6ced67161bd6700cff5406594aa934385f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Jun 2025 15:06:29 +0000 Subject: [PATCH 7/7] Add back products/ check and inline replace operations as requested Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com> --- .vitepress/config.mts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.vitepress/config.mts b/.vitepress/config.mts index f84ee47..a699f7d 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -19,8 +19,8 @@ export default defineConfig({ const repositories = JSON.parse(fs.readFileSync('repositories.json', 'utf-8')); const repositoriesMap: Map = new Map(repositories.map((repoData: RepoData) => [repoData.repository, repoData])); - const repoName = pageData.relativePath.split('/')[1]; - const repoData = repositoriesMap.get(repoName?.replace(/\d+-/g, '')); + const repoName = pageData.relativePath.split('/')[1]?.replace(/\d+-/g, ''); + const repoData = repositoriesMap.get(repoName); return { params: { @@ -159,7 +159,7 @@ export default defineConfig({ // Common calculation for repo extraction from relativePath const [_, repoName, ...rest] = relativePath.split('/') - const repoNamePath = repoName.replace(/\d+-/g, '') + const repoNamePath = repoName?.replace(/\d+-/g, '') || '' const restPath = rest.join('/') const orgName = organization || 'autumn-library'; @@ -167,8 +167,11 @@ export default defineConfig({ return `https://github.com/${orgName}/${repoNamePath}/edit/master/docs/api/${restPath}` } - // For products - return `https://github.com/${orgName}/${repoNamePath}/edit/master/docs/product/${restPath}` + if (relativePath.startsWith('products/')) { + return `https://github.com/${orgName}/${repoNamePath}/edit/master/docs/product/${restPath}` + } + + return '' } },