fix(toc): point "Edit this page on GitHub" at the current page - #663
Open
pucedoteth wants to merge 1 commit into
Open
fix(toc): point "Edit this page on GitHub" at the current page#663pucedoteth wants to merge 1 commit into
pucedoteth wants to merge 1 commit into
Conversation
`Toc` declares a `filePath` prop (Nextra passes the page's project-root relative path, e.g. `src/pages/general/rpc.mdx`) but never destructures it. The link instead used `URLS.editDocsOnGithub`, a constant set to `https://github.com/inkonchain`, so on every page the "Edit this page on GitHub" link dropped the reader on the GitHub organization landing page rather than an editor for the page they were reading. Use the prop to build the real edit URL and rename the constant to `editDocsOnGithubBase` to reflect that it is now a base, falling back to the repository URL when `filePath` is empty. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
kutluhaneth46
approved these changes
Sep 5, 2026
kutluhaneth46
left a comment
There was a problem hiding this comment.
Review
Checked the TOC “Edit this page” path end-to-end.
filePathwas already on theTocprops type but unused; wiring it into the href is the right fix.- Switching the constant to an
…/edit/mainbase + appendingfilePathproduces a real GitHub edit URL for the current MDX page instead of dumping editors on the org root.
One small follow-up (non-blocking): if filePath is ever empty/undefined at a call site, falling back to repositoryUrl is fine — worth a quick assert that every <Toc /> call site still passes filePath after this lands.
LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every page's "Edit this page on GitHub" link in the table of contents sends the reader to
https://github.com/inkonchain— the GitHub organization landing page. It never opens the page they were reading, and it does not even land on this repository.Tocalready receives what it needs to build the right link. Nextra passes the page's project-root-relative source path asfilePath(nextra/dist/server/loader.js:filePath: slash(path.relative(CWD, mdxPath))), and the prop is declared inTocProps:but it is never destructured, so it is silently dropped. The link then falls back to the constant
URLS.editDocsOnGithub, which is set to the org URL:Fix
Use the prop, and rename the constant to
editDocsOnGithubBaseso its role as a URL prefix is clear:The
filePathfallback keeps the link sane for any route Nextra renders without a source file (the theme defaultsfilePathto"").Two files, +8/-6. No behaviour outside the edit link changes.
Verification
Rendered HTML from
next dev, same page, with and without the patch:/general/connect-wallethttps://github.com/inkonchainhttps://github.com/inkonchain/docs/edit/main/src/pages/general/connect-wallet.mdxpnpm run buildsucceeds, and 44 of the pre-rendered pages in.next/server/pagesnow carry a per-page edit URL, e.g.Each resolves (HTTP 200) to GitHub's editor for that file.
pnpm run lint:js,pnpm run format:js:checkandtsc --noEmitare clean.spellcheck:lintfails onmainfor unrelated reasons — that is covered separately in #661.