Star on GitHub buttons with a live star count on the public site #328
Intentwhat this change is meant to do
Help people find Diffinery by making it easy to star the GitHub mirror from the website, showing the live star count without slowing pages or loading anything from GitHub in the visitor's browser.
test-bot merged commit 2bf0f45 into main
Pull request successfully merged and closed
test-bot merged 2bf0f45 into main
Sign in to join the conversation.
Requested by Can · project thread
#What this changes
Adds "Star on GitHub" buttons, with the GitHub mirror's live star count, to the public site: the header (signed-out visitors, every page; logo and count only on phones), the home page hero, the footer, the Open source page (next to a new "View the source" button) and under the docs' "On this page" column. Each is a plain link to https://github.com/codician-team/diffinery in GitHub's own shape (label, rule, count), using Phosphor's GithubLogo and Star icons like the rest of the UI, in light and dark.
The count (
src/web/github-stars.ts) is read by the server, never the browser: GitHub's REST API first, shields.io's JSON badge when GitHub rate-limits Workers' shared IPs. It is kept 30 minutes per isolate and in the colo's Cache API and refreshed in the background withwaitUntil, so no page waits on GitHub. Failures keep the last count and retry after 10 minutes; with no count yet the button shows no number. Without the Cache API (unit tests) GitHub isn't asked. Signed-in pages are unchanged except the docs card. The copy IndexNow compares has no count, so a new star doesn't count as a changed page.Also: a stars badge in the README and a link on its "a star on GitHub" line, and one line in the privacy policy saying the buttons are plain links and the server fetches the count.
#How it was tested
test/unit/github-stars.test.ts(fresh/stale/failure/retry behaviour, both sources, number formatting) and a site test that the home, Open source and docs pages each have three star links and load nothing from GitHub or shields.io.pnpm -r typecheckandpnpm -r testpass (1140 app tests).pnpm devsigned out: the count showed 32 from the real sources; screenshots at desktop and phone widths, light and dark, in the project'sgithub-stars/after/.#Checklist
pnpm -r typecheckandpnpm -r testpassapps/diffinery/docs(site UI only; privacy page updated)apps/diffinery/migrations(none)🤖 Generated with Claude Code
https://claude.ai/code/session_01PJMruGSY3MDW2doSyDDH7F