Fix broken docs "Edit page" links via correct astro config editLink.baseUrl#1180
Fix broken docs "Edit page" links via correct astro config editLink.baseUrl#1180Copilot wants to merge 4 commits into
Conversation
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes broken docs “Edit page” links by normalizing malformed GitHub URLs emitted via Astro.locals.starlightRoute.editUrl, ensuring they resolve to valid GitHub file URLs while leaving already-correct /edit/ and /blob/ links untouched.
Changes:
- Add GitHub URL normalization logic to the custom Starlight
EditLinkoverride. - Replace the Starlight default
EditLinkcomponent usage with an explicit<a>that uses the normalized URL. - Add unit test coverage for malformed-vs-valid GitHub edit URLs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/frontend/src/components/starlight/EditLink.astro | Normalizes malformed GitHub URLs and renders the edit link using the corrected URL. |
| src/frontend/tests/unit/edit-link.vitest.test.ts | Adds regression tests for URL normalization and ensuring valid edit URLs are preserved. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hey @copilot, wasn't an easier fix to adjust the astro config itself instead? |
… editLink.baseUrl Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Yes, you're right. The root cause was that I've reverted |
|
This PR now appears to have no changes? Closing. Reopen if necessary. |
Please work on implementing the |
The editLink: {
- baseUrl: 'https://github.com/microsoft/aspire.dev/main/src/frontend/',
+ baseUrl: 'https://github.com/microsoft/aspire.dev/edit/main/src/frontend/',
},This PR branch was created after that commit landed, so the branch already starts with the correct config value — hence 0 files changed. The root cause is resolved on |
The docs "Edit page" anchor was rendering a malformed GitHub URL missing the verb segment between repo and branch (for example,
.../aspire.dev/main/...), which leads to 404s. The root cause was thateditLink.baseUrlinastro.config.mjshad the/edit/verb stripped in an earlier commit, producing URLs likehttps://github.com/microsoft/aspire.dev/main/src/frontend/...instead of the correcthttps://github.com/microsoft/aspire.dev/edit/main/src/frontend/....The fix is to ensure the
editLink.baseUrlinastro.config.mjsretains the correct form with the action verb — no component-level workaround is needed.editLink.baseUrlwas incorrectly set tohttps://github.com/microsoft/aspire.dev/main/src/frontend/(missing/edit/), causing Starlight to produce malformed edit URLs.https://github.com/microsoft/aspire.dev/edit/main/src/frontend/is confirmed in place. The customEditLinkcomponent continues to use Starlight'sDefaultEditLink, relying on the config to produce valid URLs.