Skip to content

Fix editLink for products not accounting for orgName from repositories.json #74

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 7 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from 5 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
21 changes: 10 additions & 11 deletions .vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default defineConfig({
const repositoriesMap: Map<string, RepoData> = new Map(repositories.map((repoData: RepoData) => [repoData.repository, repoData]));

const repoName = pageData.relativePath.split('/')[1];
const repoData = repositoriesMap.get(repoName);
const repoData = repositoriesMap.get(repoName?.replace(/\d+-/g, ''));
Copy link
Member

Choose a reason for hiding this comment

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

Move replace to the line with repoName calculation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved replace operation inline with repoName calculation in both transformPageData and editLink pattern. Now uses repoName?.replace(/\d+-/g, '') directly in the assignment. Commit f9a40a6


return {
params: {
Expand Down Expand Up @@ -157,19 +157,18 @@ export default defineConfig({
const filePath = pageData.filePath
const organization = pageData.params?.organization;

const [_, repoName, ...rest] = filePath.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)
Copy link
Member

Choose a reason for hiding this comment

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

нене, вот здесь (и на 160 строке) как раз можно проверить relativePath. там же должно быть и /api и /product по идее.
ну и вырни обратно обший расчет repoName, orgName и restPathю они же одинаковые в таком случае

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to use relativePath for path checks and restored common calculation of repoName, orgName and restPath as requested. Commit 718e717

Copy link
Member

Choose a reason for hiding this comment

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

Vitepress хостит не только /api и /product. Верни проверку на product обратно

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added back specific check for relativePath.startsWith('products/') instead of using catch-all. Now properly handles cases where VitePress hosts paths other than /api and /product by returning empty string for unmatched paths. Commit f9a40a6

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added back specific check for relativePath.startsWith('products/') instead of using catch-all. Now properly handles cases where VitePress hosts paths other than /api and /product by returning empty string for unmatched paths. Commit f9a40a6

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}`
}
},

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.