From 2b97b26799155f5ede51f47c774c59151a96a7bf Mon Sep 17 00:00:00 2001 From: jamesconwaydev <148910373+jamesconwaydev@users.noreply.github.com> Date: Thu, 5 Nov 2026 19:49:44 -0700 Subject: [PATCH] fix(site): serve the README's dynamic badges from the site GitHub's image proxy times out on dynamic shields.io badges. The listed and Scorecard badges are now SVGs built with the site (badge.svg, scorecard.svg); discussions and website are static shields badges. Scorecard is fetched at build time with a 10s timeout and falls back to a grey "pending" badge. badge.json is unchanged. The build job's harden-runner is in audit mode, so egress to api.scorecard.dev is open. --- README.md | 8 ++--- site/src/lib/embeds.ts | 18 +++++++++- site/src/pages/badge.svg.ts | 9 +++++ site/src/pages/scorecard.svg.ts | 21 ++++++++++++ site/tests/badges.test.mjs | 58 +++++++++++++++++++++++++++++++++ 5 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 site/src/pages/badge.svg.ts create mode 100644 site/src/pages/scorecard.svg.ts create mode 100644 site/tests/badges.test.mjs diff --git a/README.md b/README.md index 33119f7..2372865 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,12 @@
Awesome lists rot. That link someone merged in 2019 is still sitting there, long after the repo's last commit, and the star count beside it only tells you who got excited once. DevStream checks a repo before it lands and again every week. Then it ranks what survives by Likes, one per account. diff --git a/site/src/lib/embeds.ts b/site/src/lib/embeds.ts index b1a91c5..2121fb9 100644 --- a/site/src/lib/embeds.ts +++ b/site/src/lib/embeds.ts @@ -12,7 +12,7 @@ const W = 720; const ROW = 44; const TOP = 76; -const esc = (v: unknown) => +export const esc = (v: unknown) => String(v) .replace(/&/g, "&") .replace(/ ({ message: `${live.length} ${live.length === 1 ? "repo" : "repos"}`, color: BRAND_HEX, }); + +// shortcut: widths are estimated at 6.6px a character, not measured; fine for short ASCII labels. +export function flatBadge(label: string, message: string, color: string): string { + const lw = Math.round(label.length * 6.6 + 10); + const rw = Math.round(message.length * 6.6 + 10); + const w = lw + rw; + const t = (x: number, s: string) => + `