Skip to content

feat(web): link the game's rules CMS page from the game sidebar - #402

Open
coyotte508 wants to merge 4 commits into
mainfrom
moon/game-sidebar-rules-link
Open

feat(web): link the game's rules CMS page from the game sidebar#402
coyotte508 wants to merge 4 commits into
mainfrom
moon/game-sidebar-rules-link

Conversation

@coyotte508

@coyotte508 coyotte508 commented Aug 24, 2026

Copy link
Copy Markdown
Member

What

On a live game's page (/game/[gameId]), the sidebar now shows a Rules link — book icon + label — when a <game>:rules CMS 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

  • Probe: the game page's load (game/[gameId]/+page.ts) fetches GET /api/page/<game>:rules alongside getGameInfo/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).
  • UI: GameSidebar.svelte renders the link as its own row right under the clock/timing meta row, with a new IconBook (Bootstrap book-half, matching the icon set). Uses resolve() for the route.
  • i18n: gameSidebar.rules added to en.json ("Rules") and de.json ("Regeln") — based on main with feat(web): multi-language site UI with SSR detection (en/de) (#306) #392 merged.

Tests

  • New routes/game/[gameId]/page.spec.ts: load returns the rules-page title when the CMS page exists, null on 404, null (and the game still loads) when the pages api throws.
  • New components/Game/GameSidebar.spec.ts: link to /page/<game>/rules shown 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:rules CMS page created):

Rules link in the game sidebar

German locale (lang=de → "Regeln"):

Regeln-Link in der Seitenleiste

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).
@github-actions

Copy link
Copy Markdown

🎮 Preview deployed

Every preview user's password is password (e.g. coyotte508 / password).

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