Skip to content

Fix editLink для продуктов не учитывает orgName из repositories.json #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 11, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default defineConfig({
return {
params: {
organization: repoData?.organization,
repository: repoData?.repository,
}
}

Expand Down Expand Up @@ -156,8 +157,23 @@ export default defineConfig({

const relativePath = pageData.relativePath
const organization = pageData.params?.organization;
const repository = pageData.params?.repository;

// If we have repository info from params, use it directly
if (organization && repository) {
const [_, ...rest] = relativePath.split('/')
const restPath = rest.join('/')

if (relativePath.startsWith('api/')) {
return `https://github.com/${organization}/${repository}/edit/master/docs/api/${restPath}`
}

if (relativePath.startsWith('products/')) {
return `https://github.com/${organization}/${repository}/edit/master/docs/product/${restPath}`
}
}

// Common calculation for repo extraction from relativePath
// Fallback to old logic for paths that don't have repo info
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete fallback logic, just return ''

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ещё разок

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed fallback logic as requested - now just returns empty string when organization and repository data is not available. This ensures only reliable edit links are shown. Fixed in 8f6637e.

const [_, repoName, ...rest] = relativePath.split('/')
const repoNamePath = repoName?.replace(/\d+-/g, '') || ''
const restPath = rest.join('/')
Expand Down