-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
…[0] instead of split[1] Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
…ework-elements) Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
.vitepress/config.mts
Outdated
|
|
||
| // Common calculation for repo extraction from relativePath | ||
| // Fallback to old logic for paths that don't have repo info |
There was a problem hiding this comment.
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 ''
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ещё разок
There was a problem hiding this comment.
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.
Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
.vitepress/config.mts
Outdated
|
|
||
| if (pageData.relativePath.startsWith('api/')) { | ||
| // For API paths, repository name is in the second segment after rewrite | ||
| repoName = pageData.relativePath.split('/')[1]?.replace(/\d+-/g, '') || ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Разве для relativePath нужно применять корректирующий replace? Проверь в логах.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely correct! The replace operation was unnecessary. After URL rewrites, the relativePath already has numbers stripped out:
api/000-autumn/...→api/autumn/...(no numbers in "autumn")products/003-extends/...→extends/...(no numbers in "extends")
The replace(/\d+-/g, '') operations were redundant. Fixed in 780c011.
.vitepress/config.mts
Outdated
| return `https://github.com/${orgName}/${repoNamePath}/edit/master/docs/product/${restPath}` | ||
| // For product pages - use filePath to determine if it's autumn docs | ||
| if (pageData.filePath && pageData.filePath.includes('products/000-autumn')) { | ||
| // This is autumn documentation at root level - path after first segment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кажется, ты здесь ошибся. Для autumn rest будет начиная с первого сегмента. Перепроверь эту функцию целиком.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely correct! For autumn docs, rest should include all segments from the relativePath. After URL rewrite, autumn paths like getting-started/about-autumn.md should use the entire path, not skip the first segment. Fixed the logic to use const restPath = relativePath for autumn docs while keeping the segment skipping for other repositories. Edit links now work correctly - fixed in 81275ef.
Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
…first segment Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
.vitepress/config.mts
Outdated
| } else { | ||
| // Use filePath to determine if this is autumn documentation | ||
| // pageData.filePath contains the original path before rewrites | ||
| if (pageData.filePath && pageData.filePath.includes('products/000-autumn')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно для всех вариантов использовать filePath, разве нет?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right! I've simplified the logic to use filePath consistently for all variants instead of the mixed approach. Now both API and product paths extract repository names from filePath by parsing the directory structure (api/000-autumn → autumn, products/003-extends → extends) rather than mixing relativePath and filePath approaches. This is much cleaner and more consistent. Fixed in c824520.
…ed approach Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
The editLink pattern for products was not correctly using the organization name from repositories.json for external repositories.
Problem:
For the repository
nixel2007/extends, the generated edit link was incorrectly pointing toautumn-library/extendsinstead of the correctnixel2007/extends. This occurred because the editLink pattern function was trying to extract repository information from the rewritten path (after URL rewrites), but the rewritten path no longer contained the repository name in the expected format.Root Cause:
transformPageDatacorrectly extracted organization from the original path (products/003-extends/010-index.md)rewrites()function transformed the path toextends/index.mdeditLink.patterntried to parse the rewritten path and incorrectly extractedrepoNameas "index.md" instead of "extends"Solution:
transformPageDatato store bothorganizationandrepositoryin page paramseditLink.patternto use the stored repository information instead of parsing the rewritten pathBefore:
After:
Testing:
nixel2007/extendsnow generates correct URL:https://github.com/nixel2007/extends/edit/master/docs/product/index.mdautumn-libraryrepositories continue to work correctlyFixes #73.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.