Skip to content

Play page in Astro: shared header, cached engine, offline file built from it - #10

Merged
AdminGodZ merged 1 commit into
mainfrom
play-astro
Nov 20, 2026
Merged

AdminGodZ merged 1 commit into
mainfrom
play-astro

Conversation

@AdminGodZ

Copy link
Copy Markdown
Owner

/play used to be a standalone HTML file (web/page.html): its own copy of the styles and fonts, with the whole engine inlined as base64. Since the site serves HTML with max-age=0, every visit downloaded 1.36 MB again. This PR moves it into Astro.

What changes

  • Astro page: /play is now src/pages/play.astro with src/components/game/, on the site's layout, so it has the same header and footer as the homepage.
    • Layout uses Tailwind. The charts, which the script draws, keep their CSS. The logic is game.ts.
  • Cached engine: scripts/prepare.sh builds broadside.wasm, and Vite serves it under a hashed name, so browsers keep it in their cache. The page is now 15 KB instead of 1.36 MB per visit.
  • Offline file: scripts/offline.mjs runs after the build. It folds /play into one self-contained dist/broadside.html, with styles, fonts, script and engine inline. It fails the build if anything would be left behind.
    • The site serves that file for "Save it for offline play", which therefore works without a GitHub release.
    • The release workflow attaches the same file.
  • Removed web/: README, CLAUDE.md, CI and release.yml now build through the site.
  • Smaller fixes:
    • The header links (/#download, /#how) also work from /play.
    • Button renders a real <button> when it has no href.
  • Homepage replay: the caption shows the shot count only ("Shot 31"), not which ships are sunk.

Checks

  • npm run check: 0 errors, 0 warnings, 0 hints
  • npm run build: passes, and writes dist/broadside.html (1.84 MB)
  • cargo fmt --check and cargo clippy -D warnings: pass. Rust is unchanged.
  • Checked in a browser:
    • /play: the header and footer match the homepage. I placed a ship, played four turns, resigned, and the game-over box showed.
    • Offline file: I served it alone in an empty folder. It loaded no other files, its fonts and logo were inline, the game ran, and its links point to broadside.admingod.ch.
    • Homepage: the replay caption shows "Shot N" only. The offline link serves /broadside.html with a download attribute (200, 1.8 MB).

…file built from it

- /play is now an Astro page (src/pages/play.astro, src/components/game/) on the site's
  layout, so it has the same header and footer as the homepage. Layout in Tailwind; the
  charts, which the script draws, keep their CSS. The logic is game.ts.
- The engine is no longer base64 inside the HTML: scripts/prepare.sh builds broadside.wasm
  and Vite serves it under a hashed name, cached for good. The page is 15 KB instead of
  1.36 MB on every visit.
- scripts/offline.mjs (postbuild) folds /play into one self-contained dist/broadside.html
  (styles, fonts, script and engine inline). The site serves it for "Save it for offline
  play", which therefore no longer waits on a release; the release attaches the same file.
- web/ is gone (page.html was a second copy of the page). README, CLAUDE.md, CI and the
  release workflow build through the site instead.
- Header links to /#download and /#how work from /play too. Button renders a real
  <button> when it has no href.
- Homepage replay: the caption shows the shot count only, not which ships are sunk.
@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
broadside Ready Ready Preview Nov 20, 2026 6:50pm UTC

@AdminGodZ
AdminGodZ merged commit 9cc9cba into main Nov 20, 2026
4 checks passed
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