-
Notifications
You must be signed in to change notification settings - Fork 2
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
Changes from 6 commits
5efdd92
2e05593
a6453c2
63ccb0a
816719e
718e717
f9a40a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, '')); | ||
|
||
return { | ||
params: { | ||
|
@@ -154,22 +154,21 @@ export default defineConfig({ | |
text: 'Редактировать страницу', | ||
pattern: ( pageData ) => { | ||
|
||
const filePath = pageData.filePath | ||
const relativePath = pageData.relativePath | ||
const organization = pageData.params?.organization; | ||
|
||
const [_, repoName, ...rest] = filePath.split('/') | ||
// Common calculation for repo extraction from relativePath | ||
const [_, repoName, ...rest] = relativePath.split('/') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. что-то не сходится. раз это до рерайтов, значит, здесь имя репозитория будет с цифрами в начале. в filePath цифр уже быть не должно, а значит и replace строкой ниже уже не нужен. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right about the logic. I'm using There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Changed to use filePath instead of relativePath and removed the manual cleaning since filePath is already processed by URL rewrites. Commit 816719e |
||
const repoNamePath = repoName.replace(/\d+-/g, '') | ||
const restPath = rest.join('/') | ||
const orgName = organization || 'autumn-library'; | ||
|
||
if (filePath.startsWith('api/')) { | ||
if (relativePath.startsWith('api/')) { | ||
return `https://github.com/${orgName}/${repoNamePath}/edit/master/docs/api/${restPath}` | ||
} | ||
|
||
if (filePath.startsWith('products/')) { | ||
return `https://github.com/${orgName}/${repoNamePath}/edit/master/docs/product/${restPath}` | ||
} | ||
return '' | ||
// For products | ||
return `https://github.com/${orgName}/${repoNamePath}/edit/master/docs/product/${restPath}` | ||
} | ||
}, | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Move replace to the line with repoName calculation
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.
Moved replace operation inline with repoName calculation in both
transformPageData
andeditLink
pattern. Now usesrepoName?.replace(/\d+-/g, '')
directly in the assignment. Commit f9a40a6