Skip to content

fix(toc): point "Edit this page on GitHub" at the current page - #663

Open
pucedoteth wants to merge 1 commit into
inkonchain:mainfrom
pucedoteth:fix/edit-this-page-link
Open

fix(toc): point "Edit this page on GitHub" at the current page#663
pucedoteth wants to merge 1 commit into
inkonchain:mainfrom
pucedoteth:fix/edit-this-page-link

Conversation

@pucedoteth

Copy link
Copy Markdown

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.

Toc already receives what it needs to build the right link. Nextra passes the page's project-root-relative source path as filePath (nextra/dist/server/loader.js: filePath: slash(path.relative(CWD, mdxPath))), and the prop is declared in TocProps:

interface TocProps {
  toc: Heading[];
  filePath: string;
}

export const Toc: React.FC<TocProps> = ({ toc: headings }) => {

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:

editDocsOnGithub: "https://github.com/inkonchain",

Fix

Use the prop, and rename the constant to editDocsOnGithubBase so its role as a URL prefix is clear:

editDocsOnGithubBase: "https://github.com/inkonchain/docs/edit/main",
const editUrl = filePath
  ? `${URLS.editDocsOnGithubBase}/${filePath}`
  : URLS.repositoryUrl;

The filePath fallback keeps the link sane for any route Nextra renders without a source file (the theme defaults filePath to "").

Two files, +8/-6. No behaviour outside the edit link changes.

Verification

Rendered HTML from next dev, same page, with and without the patch:

href on /general/connect-wallet
before https://github.com/inkonchain
after https://github.com/inkonchain/docs/edit/main/src/pages/general/connect-wallet.mdx

pnpm run build succeeds, and 44 of the pre-rendered pages in .next/server/pages now carry a per-page edit URL, e.g.

https://github.com/inkonchain/docs/edit/main/src/pages/faq.mdx
https://github.com/inkonchain/docs/edit/main/src/pages/index.mdx
https://github.com/inkonchain/docs/edit/main/src/pages/status.mdx

Each resolves (HTTP 200) to GitHub's editor for that file.

pnpm run lint:js, pnpm run format:js:check and tsc --noEmit are clean. spellcheck:lint fails on main for unrelated reasons — that is covered separately in #661.

`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>
@pucedoteth
pucedoteth requested a review from a team as a code owner September 4, 2026 22:56

@kutluhaneth46 kutluhaneth46 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review

Checked the TOC “Edit this page” path end-to-end.

  • filePath was already on the Toc props type but unused; wiring it into the href is the right fix.
  • Switching the constant to an …/edit/main base + appending filePath produces 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants