Repository navigation
Conversation
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.
✅ Deploy Preview for openzeppelin-docs-v2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@andrew-fleming could you please double check the docs side. |
andrew-fleming
left a comment
There was a problem hiding this comment.
Looking good @0xisk! I left some comments and suggestions. Also, we need to update the compact urls in ecosystems.json (add the version)
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.
andrew-fleming
left a comment
There was a problem hiding this comment.
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
| // 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; | ||
| } |
There was a problem hiding this comment.
| // 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); |
There was a problem hiding this comment.
| 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"; |
There was a problem hiding this comment.
| const BASE = "/contracts-compact"; | |
| const LATEST_TOKEN = "{{latest}}"; |
| { | ||
| "type": "page", | ||
| "name": "Overview", | ||
| "url": "/contracts-compact" |
There was a problem hiding this comment.
| "url": "/contracts-compact/{{latest}}" |
If you like the proposed suggestions in index.ts, we'd apply it like this
Documentation Pull Request
Summary
Gives Contracts for Compact the
contracts-cairolayout: the current pages move to0.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 under0.3.x/and 0.4.0 under0.4.x/instead of overwriting the previous line.Type of Change
Related Issues
Relates to #258
Checklist
pnpm run buildpnpm run checkAdditional Notes
Not visible in the diff:
0.1.x/; the catch-all sits after the0.1.x/*passthrough, same shape as the/contracts/*block.public/llms.txtwas regenerated;main's copy was stale, so it also picks up Stellar pages unrelated to this change.0.3.x/, withlatestStablebumped to0.3.xand0.1.xadded under Previous Versions. The 0.4.0 set follows the same way.