Skip to content

RepoCard: surface live demos with screenshot + caption#26

Merged
zhawtof merged 1 commit into
mainfrom
claude/thirsty-knuth-97089e
May 18, 2026
Merged

RepoCard: surface live demos with screenshot + caption#26
zhawtof merged 1 commit into
mainfrom
claude/thirsty-knuth-97089e

Conversation

@zhawtof
Copy link
Copy Markdown
Contributor

@zhawtof zhawtof commented May 18, 2026

Summary

  • Three featured repos (block-kitchen, slack-block-kit-validator, storybook-addon-slack-block-kit) have publicly hosted live demos — but the landing page didn't show them. Visitors had no way to know they could click and play with a working thing. This PR surfaces each demo as a screenshot + caption on its RepoCard, with the screenshot link going to the demo and the rest of the card still going to GitHub.
  • Naming follows a consistent block-kit-* family: block-kitchen.tightknit.dev, block-kit-validator.tightknit.dev, block-kit-storybook.tightknit.dev.
  • Screenshots are captured by a Playwright script and committed to src/assets/demos/. Astro's image optimizer generates responsive WebP variants (~18 KB at 800w for the largest demo, down from 394 KB PNG).

What changed

src/lib/github.ts — new demoUrl: string | null field on Repo plus a DEMO_URLS map. Applied in both the live GitHub-fetch path and the manual-fallback merge so it works whether the API responds or we fall back to the hardcoded list.

src/components/RepoCard.astro — refactored from <a> wrapper to <article> with a stretched-link on the title (covers the whole card → GitHub). Below the title + description, demo-having cards render a 16:9 framed screenshot with a 3px ink border + 4px hard shadow (smaller than the card's 8px so the hierarchy stays). The screenshot link has relative z-10 so clicks on the image land on the demo URL, while every other inch of the card still goes to GitHub. A caption below the image reads ▶ Live demo · block-kit-validator.tightknit.dev →, with the host + arrow bound as a single whitespace-nowrap chunk so the arrow always stays attached to the URL when the caption wraps. Falls back to a text-only pill if a demoUrl is set but no screenshot exists yet.

Screenshots are auto-discovered via import.meta.glob('../assets/demos/*.png') keyed by repo name — adding a new demo is "drop a PNG with the right filename, done."

scripts/capture-demos.ts — Playwright script that snapshots all three demos at 1600×900 @ 2× DPR, saved as src/assets/demos/<repo-name>.png (filename must match the repo name so the glob lookup works). Run via npm run capture:demos. Uses Node 22's --experimental-strip-types so no tsx/ts-node dep. Supports --host-rules="MAP host 1.2.3.4" for the rare case of a stuck local mDNS negative cache. Continues on per-target errors; exits non-zero if any failed.

CLAUDE.md — documents npm run capture:demos and the "demos map + screenshot filename" convention.

Click-target audit

Verified via DOM probes at six points per card:

Region Destination
Meta row (tightknitai / repo-name ↗) GitHub
Title GitHub
Description GitHub
Screenshot image Demo URL
Caption (▶ Live demo · host →) Demo URL
Topics, footer GitHub

Build-time image optimization

Astro converts every PNG to 4 responsive WebP variants with srcset. Real numbers from the prod build:

File PNG WebP @ 800w
block-kitchen.png 394 KB 18 KB
slack-block-kit-validator.png 241 KB 12 KB
storybook-addon-slack-block-kit.png 205 KB 11 KB

Images are loading=\"lazy\" so they don't block first paint.

Test plan

  • npm run dev — featured row shows screenshots above block-kitchen and validator (yellow + cyan cards), with slack-hono (pink, no demo) staying text-only
  • Storybook addon card in the "rest" section shows its screenshot on the default white variant
  • Clicking the screenshot or the ▶ Live demo · ... → caption opens the demo URL in a new tab
  • Clicking anywhere else on the card opens the GitHub repo in a new tab
  • Card with a long demo URL wraps the caption to two lines without orphaning the arrow
  • npm run typecheck clean
  • npm run build produces 12 WebP variants under dist/_astro/
  • npm run capture:demos re-snapshots all three demos and overwrites the PNGs

🤖 Generated with Claude Code

Three of the featured repos (block-kitchen, slack-block-kit-validator,
storybook-addon-slack-block-kit) have publicly hosted live demos that
were previously invisible on the landing page. A working demo is the
single most persuasive thing a visitor can do with these tools, so we
now show a screenshot of each demo on its card with a caption linking
to the live URL.

What changed:

- DEMO_URLS map in src/lib/github.ts maps repo name → demo URL. Adds
  demoUrl to the Repo type and applies it in both the live-fetch and
  manual-fallback merge paths. Naming follows a block-kit-* family
  (block-kitchen.tightknit.dev, block-kit-validator.tightknit.dev,
  block-kit-storybook.tightknit.dev) so the domains are predictable.
- RepoCard.astro renders the screenshot below the title and
  description with a 3px ink border + 4px hard shadow (smaller than
  the card's 8px shadow to preserve hierarchy). Image is wrapped in
  an <a> with relative z-10 so clicks land on the demo URL; the
  card's title is a stretched-link to the GitHub repo, so every
  other inch of the card still goes to GitHub. Falls back to a text
  pill when a demoUrl is set but no screenshot exists yet.
- import.meta.glob discovers screenshots from src/assets/demos/ by
  repo name, so adding a new demo is: drop a PNG, done. astro:assets
  generates responsive WebP variants (massive: 394KB PNG →
  18KB WebP @ 800w).
- scripts/capture-demos.ts is a Playwright script that snapshots all
  three demos at 1600x900 @ 2x DPR. Run via `npm run capture:demos`
  (Node 22 --experimental-strip-types, no tsx/ts-node dep). Supports
  --host-rules= for working around stuck local DNS caches. Continues
  on per-target errors and exits non-zero if any failed.
- CLAUDE.md documents the new command and convention.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
tightknit-dev-website 9708021 Commit Preview URL

Branch Preview URL
May 18 2026, 03:28 PM

@zhawtof zhawtof merged commit 05c8565 into main May 18, 2026
2 checks passed
@zhawtof zhawtof deleted the claude/thirsty-knuth-97089e branch May 20, 2026 05:26
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