feat(web): link the game's rules CMS page from the game sidebar - #402
Open
coyotte508 wants to merge 4 commits into
Open
feat(web): link the game's rules CMS page from the game sidebar#402coyotte508 wants to merge 4 commits into
coyotte508 wants to merge 4 commits into
Conversation
When a <game>:rules CMS page exists (e.g. powergrid:rules), the live game's sidebar shows a Rules link to /page/<game>/rules, so players can check the rules mid-game (and while reviewing replays). The game page's load probes GET /api/page/<game>:rules non-fatally — a 404 or a pages-api failure just hides the link — and passes the title only through the game context. Label is i18n'd (gameSidebar.rules, en + de).
|
🎮 Preview deployed
Every preview user's password is |
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.
What
On a live game's page (
/game/[gameId]), the sidebar now shows a Rules link — book icon + label — when a<game>:rulesCMS page exists (e.g.powergrid:rules,gaia-project:rules). It links to/page/<game>/rules(the existing language-negotiating CMS route), so players can check the rules mid-game without leaving the app. Renders for active and ended games (replays too).How
game/[gameId]/+page.ts) fetchesGET /api/page/<game>:rulesalongsidegetGameInfo/getGamePreferences, with.catch(() => null)— a 404 or a pages-api failure just hides the link, it can never break the game page. Only the title is kept (the sidebar never renders the body) and threaded through the game context (rulesPage).GameSidebar.svelterenders the link as its own row right under the clock/timing meta row, with a newIconBook(Bootstrap book-half, matching the icon set). Usesresolve()for the route.gameSidebar.rulesadded toen.json("Rules") andde.json("Regeln") — based on main with feat(web): multi-language site UI with SSR detection (en/de) (#306) #392 merged.Tests
routes/game/[gameId]/page.spec.ts: load returns the rules-page title when the CMS page exists,nullon 404,null(and the game still loads) when the pages api throws.components/Game/GameSidebar.spec.ts: link to/page/<game>/rulesshown when the probe found the page, hidden otherwise.pnpm --filter @bgs/web test: 42 files / 323 tests pass ·check: 0 errors · eslint/prettier clean.Screenshots
Active game sidebar (seeded local stack,
gaia-project:rulesCMS page created):German locale (
lang=de→ "Regeln"):