Skip to content

docs(midnight): version the contracts-compact set - #265

Open
0xisk wants to merge 4 commits into
mainfrom
docs/compact-versioned-layout
Open

0xisk wants to merge 4 commits into
mainfrom
docs/compact-versioned-layout

Conversation

@0xisk

@0xisk 0xisk commented Nov 4, 2026

Copy link
Copy Markdown
Member

Documentation Pull Request

Summary

Gives Contracts for Compact the contracts-cairo layout: the current pages move to 0.1.x/, a landing page fronts the latest set, and the banner, search filter, navigation and Netlify rules learn versioned paths. Done ahead of #258 so 0.3.0 lands under 0.3.x/ and 0.4.0 under 0.4.x/ instead of overwriting the previous line.

Type of Change

  • New documentation
  • Documentation update/revision
  • Fix typos or grammar
  • Restructure/reorganize content
  • Add examples or tutorials
  • Update API documentation
  • Other: ___________

Related Issues

Relates to #258

Checklist

Additional Notes

Not visible in the diff:

  • Old flat URLs 301 to 0.1.x/; the catch-all sits after the 0.1.x/* passthrough, same shape as the /contracts/* block.
  • public/llms.txt was regenerated; main's copy was stale, so it also picks up Stellar pages unrelated to this change.
  • midnight: bump docs to v0.3.0 #258 then rebases and moves its pages under 0.3.x/, with latestStable bumped to 0.3.x and 0.1.x added under Previous Versions. The 0.4.0 set follows the same way.

Give Contracts for Compact the contracts-cairo layout before the 0.3.0 and
0.4.0 page sets land: the current pages move to 0.1.x/, a landing page
with cards fronts the latest set, and the version banner, search filter,
navigation and Netlify rules learn the versioned paths. Each release line
then keeps its own docs instead of the next release overwriting them.

Beyond the move, the 0.1.x pages change in four places: GitHub source
links are pinned to the v0.1.0 tag instead of main, api/utils.mdx and the
two token guides drop relative links that resolve inside the version
folder after the move, and the overview states that 0.2.0 shares these
pages.
@0xisk
0xisk requested review from a team and stevep0z as code owners November 4, 2026 15:28
@netlify

netlify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for openzeppelin-docs-v2 ready!

Name Link
🔨 Latest commit 020ea43
🔍 Latest deploy log https://app.netlify.com/projects/openzeppelin-docs-v2/deploys/6aec424835617a4fec12f4de
😎 Deploy Preview https://deploy-preview-265--openzeppelin-docs-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@0xisk 0xisk mentioned this pull request Nov 4, 2026
7 of 10 tasks
@0xisk

0xisk commented Nov 4, 2026 •

Copy link
Copy Markdown
Member Author

@andrew-fleming could you please double check the docs side.
@stevep0z could you please review the code changes on the src/ etc which for supporting the multi-version view

@0xisk
0xisk requested a review from andrew-fleming November 4, 2026 15:35
@0xisk 0xisk mentioned this pull request Nov 4, 2026
6 of 10 tasks

@andrew-fleming andrew-fleming left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking good @0xisk! I left some comments and suggestions. Also, we need to update the compact urls in ecosystems.json (add the version)

Comment thread content/contracts-compact/index.mdx Resolved
Comment thread public/llms.txt Resolved
Comment thread src/navigation/midnight/current.json Resolved
0xisk added 3 commits November 5, 2026 09:29
API pages take the GitHub source tag from API_SOURCE_VERSION in the
version folder's constants, as the Cairo pages do, and current.json
lists the latest set without a version segment so the navigation prefixes
it from latestStable. A version bump is then one edit per file instead
of one per page.
@0xisk
0xisk requested a review from andrew-fleming November 5, 2026 08:59

@andrew-fleming andrew-fleming left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Improvements look good! There is however a duplicate key issue with the current setup in navigation/:

Encountered two children with the same key, /contracts-compact. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.


I left some suggestions for a clean fix

Comment on lines +7 to +24
// current.json lists the latest set without a version segment; prefix every
// page but the landing so a version bump is one edit in latest-versions.js.
function versioned(node: NavigationNode): NavigationNode {
if (
node.type === "page" &&
node.url !== BASE &&
node.url.startsWith(`${BASE}/`)
) {
return {
...node,
url: `${BASE}/${latestStable}${node.url.slice(BASE.length)}`,
};
}
if (node.type === "folder") {
return { ...node, children: node.children.map(versioned) };
}
return node;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// current.json lists the latest set without a version segment; prefix every
// page but the landing so a version bump is one edit in latest-versions.js.
function versioned(node: NavigationNode): NavigationNode {
if (
node.type === "page" &&
node.url !== BASE &&
node.url.startsWith(`${BASE}/`)
) {
return {
...node,
url: `${BASE}/${latestStable}${node.url.slice(BASE.length)}`,
};
}
if (node.type === "folder") {
return { ...node, children: node.children.map(versioned) };
}
return node;
}
// current.json writes versioned URLs with a `{{latest}}` segment so a version
// bump is one edit in latest-versions.js. The landing page keeps its literal URL.
function resolveLatest(nodes: NavigationNode[]): NavigationNode[] {
return nodes.map((node) => {
switch (node.type) {
case "page":
return {
...node,
url: node.url.replaceAll(LATEST_TOKEN, latestStable),
};
case "folder":
return {
...node,
index: node.index
? {
...node.index,
url: node.index.url.replaceAll(LATEST_TOKEN, latestStable),
}
: node.index,
children: resolveLatest(node.children),
};
default:
return node;
}
});
}

return node;
}

const current = (currentData as NavigationNode[]).map(versioned);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
const current = (currentData as NavigationNode[]).map(versioned);
const current = resolveLatest(currentData as NavigationNode[]);

import type { NavigationNode } from "../types";
import currentData from "./current.json";

const BASE = "/contracts-compact";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
const BASE = "/contracts-compact";
const LATEST_TOKEN = "{{latest}}";

{
"type": "page",
"name": "Overview",
"url": "/contracts-compact"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
"url": "/contracts-compact/{{latest}}"

If you like the proposed suggestions in index.ts, we'd apply it like this

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