-
Notifications
You must be signed in to change notification settings - Fork 2.1k
doc/starlight: fix edit link for generated documents #21987
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
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| if (starlightRoute.editUrl) { | ||
| let editUrl = starlightRoute.editUrl.toString(); | ||
|
|
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.
(somehow, Github renders this suggestion weirdly. I mean: remove trailing whitespaces, please, i.e., keep the line empty)
| const filename = editUrl.split(generatedPath)[1]; | ||
| editUrl = editUrl.split(generatedPath)[0] + '/' + filename; | ||
| } | ||
|
|
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.
Here too.
| const filename = editUrl.split(generatedPath)[1]; | ||
| editUrl = editUrl.split(generatedPath)[0] + '/' + filename; |
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.
As far as I understand this (very weird; why not just use '/' as a token and use the first and last element of the string) parsing step, this basically assumes that all files were generated from root. This invites potential footguns IMHO and also might lead to maybe unrelated files (something about boards/ e.g.) hogging the already quite crowded root path. I'd rather have a mapping somewhere, where the name of the generated file is mapped to the original source. It can be in this file, but maybe it makes sense to hook this directly into the generation somehow. This way, we would avoid risks of the generation and the edit links going potentially out of sync.
Contribution description
@miri64 noticed that the edit link was broken when the site was generated using one of the root markdown files, this should fix that.
Testing procedure
make doc-starlightand then click on the edit page link on e.g. SecurityIssues/PRs references