From 7c81c423abd98d74833de89d0af050220bd6e5a0 Mon Sep 17 00:00:00 2001 From: Yejin Kelly Joo Date: Thu, 16 Jul 2026 16:40:27 +0900 Subject: [PATCH 1/5] feat(scripts): mirror swarm-cheatsheets into static at build time - add scripts/fetch-cheatsheets.mjs to fetch the cheatsheet page, assets, and PDF from swarm-cheatsheets@main and mirror them into static/cheatsheets/ with asset paths rewritten - fetch files concurrently with a per-request timeout, prune the output dir first, and fail the build on any fetch error - wire the script into the prebuild chain and gitignore the generated static/cheatsheets output Co-Authored-By: Claude Opus 4.8 (1M context) Signed-off-by: Yejin Kelly Joo --- .gitignore | 1 + package.json | 2 +- scripts/fetch-cheatsheets.mjs | 101 ++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 scripts/fetch-cheatsheets.mjs diff --git a/.gitignore b/.gitignore index 62066d1d6..942a52497 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ resources .netlify /src/pages/awesome-swarm.mdx /static/openapi.yaml +/static/cheatsheets test docs/references/awesome-list.mdx *.zip diff --git a/package.json b/package.json index 70f7a42f2..8379aaff9 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "docusaurus": "docusaurus", "start": "docusaurus start", - "prebuild": "node -e \"require('fs').copyFileSync('openapi/Swarm.yaml', 'static/openapi.yaml')\" && node scripts/fetch-awesome-swarm.mjs && node scripts/validate-llms-txt.mjs", + "prebuild": "node -e \"require('fs').copyFileSync('openapi/Swarm.yaml', 'static/openapi.yaml')\" && node scripts/fetch-awesome-swarm.mjs && node scripts/fetch-cheatsheets.mjs && node scripts/validate-llms-txt.mjs", "build": "docusaurus build", "build:quiet": "cross-env NODE_OPTIONS=\"--disable-warning=DEP0040 --disable-warning=DEP0169\" docusaurus build", "swizzle": "docusaurus swizzle", diff --git a/scripts/fetch-cheatsheets.mjs b/scripts/fetch-cheatsheets.mjs new file mode 100644 index 000000000..08787e46d --- /dev/null +++ b/scripts/fetch-cheatsheets.mjs @@ -0,0 +1,101 @@ +// Mirror the Swarm cheatsheet(s) from the swarm-cheatsheets repo into static/, +// so they are served from our own domain (docs.ethswarm.org/cheatsheets/…) and +// embedded in a doc page via + +Open the cheatsheet in a new tab diff --git a/sidebars.js b/sidebars.js index f2eba68d4..9d5e29817 100644 --- a/sidebars.js +++ b/sidebars.js @@ -107,6 +107,7 @@ module.exports = { items: [ 'develop/tools-and-features/introduction', 'develop/tools-and-features/ai-agent-skills', + 'develop/tools-and-features/cheatsheets', 'develop/tools-and-features/buy-a-stamp-batch', 'develop/tools-and-features/bee-js', 'develop/tools-and-features/gateway-proxy', diff --git a/static/llms.txt b/static/llms.txt index c4e44db59..96760dcc4 100644 --- a/static/llms.txt +++ b/static/llms.txt @@ -63,6 +63,7 @@ This is the documentation for [Swarm](https://www.ethswarm.org/) and its referen - [Bee JS](https://docs.ethswarm.org/docs/develop/tools-and-features/bee-js): JavaScript/TypeScript SDK for Swarm - [AI Agent Skills](https://docs.ethswarm.org/docs/develop/tools-and-features/ai-agent-skills): Claude Code skills that guide Swarm setup and building +- [Swarm Cheatsheet](https://docs.ethswarm.org/cheatsheets/overview/): Printable quick-reference — what Swarm is/isn't, limitations, quickstart, and curated links for building on Swarm - [Chunk Types](https://docs.ethswarm.org/docs/develop/tools-and-features/chunk-types): Content-addressed chunks (CAC) and single-owner chunks (SOC) - [Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds): Mutable data references using single-owner chunks - [Manifests](https://docs.ethswarm.org/docs/develop/tools-and-features/manifests): Trie-based path mapping for file collections From d9eb1862dae69b9be2d3ff73086670952ad1834b Mon Sep 17 00:00:00 2001 From: Yejin Kelly Joo Date: Thu, 16 Jul 2026 18:29:16 +0900 Subject: [PATCH 3/5] fix(develop): auto-size the Swarm Cheatsheet iframe to its content - grow the iframe to its content height on load so the page scrolls instead of the iframe - re-measure with a ResizeObserver to track reflow after fonts load and QR codes render - keep an 85vh min-height as a no-JS fallback Co-Authored-By: Claude Opus 4.8 (1M context) Signed-off-by: Yejin Kelly Joo --- docs/develop/tools-and-features/cheatsheets.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/develop/tools-and-features/cheatsheets.md b/docs/develop/tools-and-features/cheatsheets.md index 4235f5443..2573ffefc 100644 --- a/docs/develop/tools-and-features/cheatsheets.md +++ b/docs/develop/tools-and-features/cheatsheets.md @@ -13,7 +13,18 @@ It's designed to print cleanly to A4, so you can keep it beside you at a hackath src="/cheatsheets/overview/" title="Swarm Cheatsheet" loading="lazy" - style={{ width: '100%', height: '85vh', border: 0 }} + onLoad={(e) => { + // Same-origin (served from /cheatsheets/): grow the frame to its content + // height so the page scrolls, not the iframe. Re-measure on reflow (the + // card's fonts load and QR codes render after the initial load event). + const frame = e.currentTarget; + const doc = frame.contentDocument; + if (!doc) return; + const fit = () => { frame.style.height = doc.documentElement.scrollHeight + 'px'; }; + fit(); + new ResizeObserver(fit).observe(doc.documentElement); + }} + style={{ width: '100%', minHeight: '85vh', border: 0 }} > Open the cheatsheet in a new tab From 7cb1842193fb0bc440b652bf8f8feb450aba202c Mon Sep 17 00:00:00 2001 From: Yejin Kelly Joo Date: Thu, 16 Jul 2026 21:41:04 +0900 Subject: [PATCH 4/5] feat(develop): embed the card-only cheatsheet instead of the full page - mirror cheatsheet.html (the A4 card) instead of index.html, dropping the source site's chrome, toolbar, and footer from the embed - stop mirroring the chrome-only swarm-logo-white.svg - replace the card's removed Download PDF button with Download PDF and open-in-new-tab links on the doc page Co-Authored-By: Claude Opus 4.8 (1M context) Signed-off-by: Yejin Kelly Joo --- docs/develop/tools-and-features/cheatsheets.md | 6 ++++-- scripts/fetch-cheatsheets.mjs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/develop/tools-and-features/cheatsheets.md b/docs/develop/tools-and-features/cheatsheets.md index 2573ffefc..88c06f9d9 100644 --- a/docs/develop/tools-and-features/cheatsheets.md +++ b/docs/develop/tools-and-features/cheatsheets.md @@ -7,7 +7,7 @@ hide_table_of_contents: true The Swarm Cheatsheet is a dense, two-page quick-reference for building on Swarm. -It's designed to print cleanly to A4, so you can keep it beside you at a hackathon or on your desk — use the **Download PDF** button on the card below to grab a copy. +It's designed to print cleanly to A4, so you can keep it beside you at a hackathon or on your desk — use the **Download PDF** link below to grab a copy. -Open the cheatsheet in a new tab +Download PDF +  +Open in a new tab diff --git a/scripts/fetch-cheatsheets.mjs b/scripts/fetch-cheatsheets.mjs index 08787e46d..8d5f65e58 100644 --- a/scripts/fetch-cheatsheets.mjs +++ b/scripts/fetch-cheatsheets.mjs @@ -25,7 +25,6 @@ const FETCH_TIMEOUT_MS = 20000; const ASSETS = [ 'assets/favicon.png', 'assets/swarm-logo.svg', - 'assets/swarm-logo-white.svg', 'assets/vendor/qrcode.min.js', 'assets/fonts/fonts.css', 'assets/fonts/dm-mono-400-latin.woff2', @@ -63,8 +62,11 @@ async function writeOut(relPath, data) { // only) rewrites asset paths; without it the file is copied verbatim // (binary-safe). Adding a future cheatsheet is a one-line addition here. const FILES = [ - { src: 'src/cheatsheets/overview/index.html', dest: 'overview/index.html', transform: rewriteAssetPaths }, + // The card-only document (chrome/toolbar/footer live in the source's + // index.html and are intentionally excluded — we embed just the cheatsheet). + { src: 'src/cheatsheets/overview/cheatsheet.html', dest: 'overview/index.html', transform: rewriteAssetPaths }, ...ASSETS.map((rel) => ({ src: rel, dest: rel })), + // Not referenced by the card; kept so the doc page can offer a download link. { src: 'dist/swarm-overview-cheatsheet.pdf', dest: 'swarm-overview-cheatsheet.pdf' }, ]; From 00680ea51e82ea81f6bb439bf08161d01aa1d175 Mon Sep 17 00:00:00 2001 From: Yejin Kelly Joo Date: Thu, 16 Jul 2026 21:50:40 +0900 Subject: [PATCH 5/5] fix(develop): scale the embedded cheatsheet to the content width - scale the fixed A4 card to fill the doc content column, removing the grey margins beside the centered sheet and enlarging it a bit - size the wrapper to the scaled height so the page scrolls, refitting on reflow and window resize - remove the redundant open-in-new-tab link Co-Authored-By: Claude Opus 4.8 (1M context) Signed-off-by: Yejin Kelly Joo --- .../develop/tools-and-features/cheatsheets.md | 52 ++++++++++++------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/docs/develop/tools-and-features/cheatsheets.md b/docs/develop/tools-and-features/cheatsheets.md index 88c06f9d9..05edf6fac 100644 --- a/docs/develop/tools-and-features/cheatsheets.md +++ b/docs/develop/tools-and-features/cheatsheets.md @@ -9,24 +9,38 @@ The Swarm Cheatsheet is a dense, two-page quick-reference for building on Swarm. It's designed to print cleanly to A4, so you can keep it beside you at a hackathon or on your desk — use the **Download PDF** link below to grab a copy. - +
+ +
Download PDF -  -Open in a new tab