Skip to content

Default home view to Global, auto-switch to visitor's country on mount#13

Merged
MaxGhenis merged 1 commit intomainfrom
feat/default-global-with-geo
May 9, 2026
Merged

Default home view to Global, auto-switch to visitor's country on mount#13
MaxGhenis merged 1 commit intomainfrom
feat/default-global-with-geo

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Summary

Visitors landing on policybench.org used to default to the UK leaderboard (an artifact of the original sort order). This PR switches the default to Global, then on hydration upgrades the view to the visitor's country (US or UK) when timezone or browser language make it identifiable.

  • SSR renders the Global leaderboard. The page stays static-prerendered (○ /) — no per-request rendering, no extra serverless calls.
  • After hydration, App.tsx checks Intl.DateTimeFormat().resolvedOptions().timeZone and navigator.languages. Switches selectedView to us (any America/* timezone or en-us language) or uk (Europe/London or en-gb family). Anything else stays on Global.
  • The auto-switch fires once per session and respects subsequent manual selections via the country pill.

Verification

  • bunx eslint . --max-warnings=0 clean.
  • bun run build clean (output still ○ / static).
  • SSR HTML's first aria-pressed="true" country pill is now Global (was UK).

🤖 Generated with Claude Code

- SSR renders the Global leaderboard so the cached static HTML is the
  same for every visitor (no per-request rendering, keeps the page
  static-prerendered).
- After hydration, App.tsx checks the visitor's IANA timezone and
  navigator.languages and switches selectedView to "us" or "uk" when
  it can confidently identify the country. Anything that doesn't match
  (Europe outside the UK, Asia, Africa, Latin America, etc.) stays on
  Global.
- The auto-switch only fires once per session and respects subsequent
  manual selections via the country pill.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 9, 2026

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

Project Deployment Actions Updated (UTC)
policybench-site Error Error May 9, 2026 1:22am

Request Review

@MaxGhenis MaxGhenis merged commit 565e3e7 into main May 9, 2026
3 of 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