Skip to content

fix(docs): use label-based API version mapping in aztec-nr api page#22620

Closed
critesjosh wants to merge 1 commit into
backport-to-v4-next-stagingfrom
jc/docs/fix-aztec-nr-api-links-v4
Closed

fix(docs): use label-based API version mapping in aztec-nr api page#22620
critesjosh wants to merge 1 commit into
backport-to-v4-next-stagingfrom
jc/docs/fix-aztec-nr-api-links-v4

Conversation

@critesjosh

Copy link
Copy Markdown
Contributor

Summary

Mirrors the fix from #22617 (against next) on the backport-to-v4-next-staging branch, but applied to the unversioned source since this branch does not yet have a v4.2.0 versioned snapshot.

Background

The Aztec.nr API reference page in v4.2.0 on next shipped with the pre-mainnet useApiVersion logic — links pointed to /aztec-nr-api/v4.2.0/... instead of /aztec-nr-api/mainnet/... and 404'd on the live site. The root cause on next was a stale versioned snapshot, already patched in #22617.

On this branch, docs-developers/docs/aztec-nr/api.mdx still has the same stale name-based useApiVersion:

const versionName = version?.name || "current";
if (versionName === "current") return "next";
if (versionName.includes("rc") || versionName.includes("testnet")) return "testnet";
return versionName;  // ← v4.2.0 would fall through here

If a mainnet version gets cut from this branch, the new snapshot would inherit the same bug. Pre-empting that here.

Fix

Replace useApiVersion with the label-based mapping that already lives on next:

if (!version || version.name === "current") return "next";
const label = version.label || "";
if (label.startsWith("Alpha")) return "mainnet";
if (label.startsWith("Testnet")) return "testnet";
return version.name;

The Alpha (...) label comes from docusaurus.config.js for mainnet-mapped versions, so useApiVersion() resolves to "mainnet" for any future v4.2.0+ snapshot cut from this branch.

Test plan

  • Run yarn start locally on this branch and verify the Aztec.nr API Reference page renders without broken links on the current (dev) version.
  • When the next mainnet cut lands, confirm the resulting snapshot inherits the label-based logic.

The useApiVersion hook in the unversioned docs-developers source used
the old name-based fallthrough logic, so a future mainnet version cut
from this branch would produce links like /aztec-nr-api/v4.2.0/... that
404 (generated docs actually live at /aztec-nr-api/mainnet/...).

Align the source with the label-based logic already in use on next, so
any future version snapshot cut from this branch picks up the correct
mapping (Alpha -> mainnet, Testnet -> testnet).
@critesjosh

Copy link
Copy Markdown
Contributor Author

handled by #22622

@critesjosh critesjosh closed this Apr 17, 2026
auto-merge was automatically disabled April 17, 2026 01:22

Pull request was closed

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.

1 participant