Skip to content

Commit 5f63802

Browse files
committed
deploy: serve explorer at Pages root, drop playground
The playground keeps deploying to truapi-playground.dot, so remove it from the GitHub Pages build. The explorer now lives at the site root (base /truapi/), with the Rust API docs kept under /cargo_doc/. Serve a copy of the SPA index as 404.html so React Router resolves deep links on refresh, replacing the old ?p= replay shim and the playground-404 injection.
1 parent 5770a2b commit 5f63802

5 files changed

Lines changed: 9 additions & 101 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,26 @@ jobs:
4242
- name: Build Rust API docs (HTML)
4343
run: cargo doc -p truapi --no-deps
4444

45-
- name: Install playground dependencies
46-
working-directory: playground
47-
run: yarn install --frozen-lockfile
48-
49-
- name: Build playground (static export)
50-
working-directory: playground
51-
env:
52-
NEXT_PUBLIC_BASE_PATH: /truapi
53-
run: yarn build
54-
5545
- name: Install explorer dependencies
5646
working-directory: explorer
5747
run: npm ci
5848

5949
- name: Build explorer (static export)
6050
working-directory: explorer
6151
env:
62-
EXPLORER_BASE_PATH: /truapi/explorer/
52+
EXPLORER_BASE_PATH: /truapi/
6353
run: npm run build
6454

6555
- name: Assemble GitHub Pages site
6656
run: |
6757
rm -rf site
6858
mkdir -p site
69-
# Playground at root.
70-
cp -R playground/out/. site/
59+
# Explorer SPA at the site root.
60+
cp -R explorer/dist/. site/
61+
# GitHub Pages serves the site-root 404.html for every missing path.
62+
# Serving a copy of the SPA index lets React Router resolve explorer
63+
# deep links (e.g. /truapi/v/main/method/foo) on a fresh load.
64+
cp site/index.html site/404.html
7165
# truapi crate's cargo doc mounted at /cargo_doc/ with the crate's
7266
# pages flattened (no /truapi/ prefix). rustdoc HTMLs reference
7367
# static.files via `../../../static.files/`, which from
@@ -76,18 +70,8 @@ jobs:
7670
mkdir -p site/cargo_doc
7771
cp -RL target/doc/truapi/. site/cargo_doc/
7872
cp -RL target/doc/static.files site/static.files
79-
# Explorer mounted at /explorer/ (its Vite `base` path).
80-
mkdir -p site/explorer
81-
cp -R explorer/dist/. site/explorer/
8273
touch site/.nojekyll
8374
84-
- name: Add explorer SPA fallback to root 404
85-
# GitHub Pages serves only the site-root 404.html (the playground's
86-
# Next.js not-found) for every missing path, including the explorer's
87-
# client routes. Inject a shim that replays /explorer/* deep links into
88-
# the explorer index; other paths keep the playground 404.
89-
run: node scripts/inject-explorer-404.mjs site/404.html
90-
9175
- name: Upload Pages artifact
9276
uses: actions/upload-pages-artifact@v3
9377
with:

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ Alternatively, with a deployed Polkadot Desktop Host installed, navigate to
100100
## Deployment
101101

102102
Pushes to `main` trigger `.github/workflows/deploy-playground.yml`, which builds `playground/` and publishes the static export to `truapi-playground.dot` via `bulletin-deploy`.
103-
Pushes to `main` also trigger `.github/workflows/deploy-docs.yml`, which publishes the Rust API docs to GitHub Pages.
103+
Pushes to `main` also trigger `.github/workflows/deploy-docs.yml`, which publishes the explorer (at the Pages root) and the Rust API docs (under `/cargo_doc/`) to GitHub Pages.

explorer/public/404.html

Lines changed: 0 additions & 29 deletions
This file was deleted.

explorer/src/main.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,9 @@ import { BrowserRouter } from "react-router-dom";
44
import "./index.css";
55
import App from "./App";
66

7-
// Mount path, e.g. "/explorer" or "/truapi/explorer", derived from Vite's base.
7+
// Mount path, e.g. "/truapi", derived from Vite's base.
88
const basename = import.meta.env.BASE_URL.replace(/\/$/, "");
99

10-
// Replay a `?p=/<path>` query produced by the GH Pages 404 shim before the
11-
// router mounts.
12-
const params = new URLSearchParams(window.location.search);
13-
const replay = params.get("p");
14-
if (replay) {
15-
const rest = new URLSearchParams(window.location.search);
16-
rest.delete("p");
17-
const tail = rest.toString();
18-
const next =
19-
basename + replay + (tail ? `?${tail}` : "") + window.location.hash;
20-
window.history.replaceState(null, "", next);
21-
}
22-
2310
createRoot(document.getElementById("root")!).render(
2411
<StrictMode>
2512
<BrowserRouter basename={basename}>

scripts/inject-explorer-404.mjs

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)