Repository navigation
Play page in Astro: shared header, cached engine, offline file built from it - #10
Merged
Merged
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/playused 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 withmax-age=0, every visit downloaded 1.36 MB again. This PR moves it into Astro.What changes
/playis nowsrc/pages/play.astrowithsrc/components/game/, on the site's layout, so it has the same header and footer as the homepage.game.ts.scripts/prepare.shbuildsbroadside.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.scripts/offline.mjsruns after the build. It folds/playinto one self-containeddist/broadside.html, with styles, fonts, script and engine inline. It fails the build if anything would be left behind.web/: README, CLAUDE.md, CI andrelease.ymlnow build through the site./#download,/#how) also work from/play.Buttonrenders a real<button>when it has no href.Checks
npm run check: 0 errors, 0 warnings, 0 hintsnpm run build: passes, and writesdist/broadside.html(1.84 MB)cargo fmt --checkandcargo clippy -D warnings: pass. Rust is unchanged./play: the header and footer match the homepage. I placed a ship, played four turns, resigned, and the game-over box showed./broadside.htmlwith adownloadattribute (200, 1.8 MB).