Skip to content

Refresh home research feed: merge tools + serve retina-sharp images#1056

Merged
PavelMakarchuk merged 3 commits into
mainfrom
feat/home-research-feed-merge-tools
May 26, 2026
Merged

Refresh home research feed: merge tools + serve retina-sharp images#1056
PavelMakarchuk merged 3 commits into
mainfrom
feat/home-research-feed-merge-tools

Conversation

@PavelMakarchuk
Copy link
Copy Markdown
Contributor

@PavelMakarchuk PavelMakarchuk commented May 26, 2026

Two related fixes to the home page, bundled because both are about the "Expert policy analysis" section looking right.

1. Show newest research (posts + tools) instead of posts-only

  • The section was pulling only blog posts, so it lagged by ~2 months on /us and missed recent UK tools on /uk. The team is shipping interactive tools (CliffWatch, South Carolina 2026, Coverage Compass, West Virginia SB 392, Working Parents Tax Relief Act) faster than written posts.
  • Switches HomeBlogPreview from getPostsSorted() to getResearchItems(), which merges posts + apps with displayWithResearch: true into one newest-first feed (same logic the /research page already uses).
  • Cards route by item type: posts use Next.js Link to /<country>/research/<slug>; apps (served via Vercel rewrites) use a plain <a> to /<countryId>/<slug> so the request hits the rewrite instead of a client-side 404. CTA flips to "Open" for apps, "Read more" for posts.

What changes for /us

Before (Jan–Mar 2026): Keep Your Pay Act post, State income tax model, TANF modeling, SC H.3492 analysis, RI McKee CTC analysis.
After (Apr–May 2026): South Carolina 2026 calculator, Missouri tax elimination calculator, Coverage Compass, West Virginia SB 392 calculator, State EITCs and CTCs.

2. Serve 2× assets on retina displays via srcset

  • Images across the site looked soft on retina/high-DPI — including the cards this PR is repopulating. Cause: OptimisedImage hardcoded dpr = 1, so a 640px-slot image was fetched at 640px of data and then upscaled by the browser to ~1280 physical pixels.
  • Adds a 1x/2x srcset so the browser picks the right asset per device. Low-DPI screens keep the 1x file (no bandwidth waste); high-DPI screens get the sharper 2x. When the snapped 1x and 2x widths land in the same ALLOWED_WIDTHS bucket, the descriptor is dropped to avoid double-fetching identical files.
  • Refactors bypass conditions (external URLs, SVGs, /_next/*, dev mode, missing width) into shouldSkipOptimisation() so the render branch reads as straight srcset construction.
  • Affects every consumer of OptimisedImage: home, blog/research cards, team photos, events, citations, tracker preview.

Test plan

  • Load /us on a retina display: 5 newest research items (mix of posts + tools) appear and render sharply
  • Load /uk: UK-only items show, also sharp
  • Click an app card (e.g. CliffWatch) → loads via Vercel rewrite, no 404
  • Click a post card → Next.js routes to /<country>/research/<slug>
  • CTAs read "Open →" for apps, "Read more →" / "Read →" for posts
  • DevTools → Network → Img: image requests use &w= ≈ 2× the rendered width on retina
  • DevTools device emulation with DPR=1: smaller w= is fetched instead

🤖 Generated with Claude Code

The "Expert policy analysis" section was pulling only blog posts, but
the team has been shipping interactive tools (CliffWatch, South Carolina
2026, Coverage Compass, etc.) faster than written posts. As a result the
home preview was lagging by ~2 months on /us and missing recent UK tools
on /uk.

Switches HomeBlogPreview from getPostsSorted() to getResearchItems(),
which merges posts + apps with displayWithResearch into one newest-first
feed. Cards now route correctly per item type: posts continue to use
Next.js Link to /<country>/research/<slug>, while apps (served via
Vercel rewrites) use a plain <a> to /<countryId>/<slug> so the request
hits the rewrite instead of a client-side 404. CTA flips to "Open"
for apps and "Read more" for posts.

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

vercel Bot commented May 26, 2026

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

Project Deployment Actions Updated (UTC)
policyengine-app-v2 Ready Ready Preview, Comment May 26, 2026 12:55pm
policyengine-calculator Ready Ready Preview, Comment May 26, 2026 12:55pm
policyengine-calculator-next Ready Ready Preview, Comment May 26, 2026 12:55pm
policyengine-website Ready Ready Preview, Comment May 26, 2026 12:55pm

Request Review

OptimisedImage hardcoded dpr = 1, so an image asked to fill a 640px slot
was fetched at 640px and then upscaled by the browser to ~1280 physical
pixels on every retina/high-DPI display — visibly soft across hero,
team photos, blog/research cards, and tracker thumbnails.

Switches to a 1x/2x srcset: the browser picks the right asset per
device. Low-DPI screens keep using the 1x file (no bandwidth waste),
high-DPI screens get the sharper 2x. When the snapped 1x and 2x widths
collide (e.g. both round to the same ALLOWED_WIDTHS bucket) we drop the
descriptor so the browser doesn't double-fetch the same file.

Also factored out the bypass conditions into shouldSkipOptimisation()
so the main render branch reads as straight srcset construction.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Right-column cards (SecondaryCard) were passing width=384 to
OptimisedImage, but they actually render at the same ~600 CSS px as the
left-column cards because the grid is two equal columns. At DPR=2 the
browser needs ~1200 physical pixels of data; the 384-hint 2x snapped
only to 828 → still upscaled → still soft on retina. Bumping to 640
matches the primary cards, snapping the 2x to 1920 — plenty sharp.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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