Skip to content

Homepage catalogue counts derive from single source of truth - #17

Merged
Ashwask merged 1 commit into
mainfrom
homepage-catalog-counts-single-source
Aug 2, 2026
Merged

Homepage catalogue counts derive from single source of truth#17
Ashwask merged 1 commit into
mainfrom
homepage-catalog-counts-single-source

Conversation

@Ashwask

@Ashwask Ashwask commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Problem

The homepage showed four "Projects" numbers from three different places, and they had drifted apart:

Where Source Was
Stats bar "Projects" (#statProjects) inline catalogProjects.length 51
Preview card "N Projects" (#catalogCount) hardcoded literal 48
"Delivered by 15 climate projects…" hardcoded text + 11 i18n files 15
Real catalogue (catalog/catalog-data.js) source of truth 53

Adding a project via the documented flow (edit catalog-data.js) moved none of the homepage numbers, because the homepage kept its own duplicated project array and baked the counts into markup.

Fix

  • Load /catalog/catalog-data.js on the homepage and derive catalogProjects from window.CATALOG_PROJECTS — the same single source of truth the catalogue page and admin already use.
  • Remove the duplicated inline array; keep only a curated id -> image lookup for showcase visuals, with a theme-icon fallback for entries without a curated image (e.g. new projects 52 & 53).
  • Set #catalogCount and #statProjects from catalogProjects.length up front (no network dependency).
  • Replace the hardcoded 48 with a - placeholder, consistent with the stats bar — no count baked into markup.

Now all catalogue counts track catalog-data.js automatically.

Not changed (on purpose)

The "Delivered by 15 climate projects in our catalogue" line is an editorial impact claim, not a catalogue total (only 5 projects are themed Energy & Climate). There is no source field marking which projects delivered the climate impact stats, so it can't be honestly auto-derived yet — left as-is. Happy to add a climateImpact flag to catalog-data.js in a follow-up if we want this derived too.

Verification

Ran the page in headless Chrome against a local server:

  • #catalogCount53, #statProjects53 (match source length)
  • catalogue carousel renders 6 slides
  • no console/page errors

No i18n text changed, so no locale updates needed.

🤖 Generated with Claude Code

The homepage carried its own duplicated `catalogProjects` array plus two
hardcoded "Projects" numbers, so counts never updated when the real
catalogue (/catalog/catalog-data.js) changed. They had already drifted:
the stats-bar "Projects" read 51, the preview card read 48, while the
source of truth has 53 entries.

Changes:
- Load /catalog/catalog-data.js on the homepage and derive `catalogProjects`
  from window.CATALOG_PROJECTS (the single source of truth shared with the
  catalogue page and admin).
- Remove the duplicated inline project array; keep only a curated id->image
  lookup for showcase visuals, with a theme-icon fallback for entries that
  have no curated image (e.g. new projects 52 & 53).
- Set #catalogCount and #statProjects from catalogProjects.length up front
  (no network dependency), so both always match the catalogue.
- Replace the hardcoded "48" with a "-" placeholder, consistent with the
  stats bar, so no count is baked into the markup.

Note: the "Delivered by 15 climate projects" line is an editorial impact
claim (not a catalogue total) and is intentionally left unchanged; it has
no derivable source field yet.

Verified in headless Chrome: #catalogCount and #statProjects both render 53,
carousel renders 6 slides, no console errors.

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

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
notf Ready Ready Preview Aug 2, 2026 8:31am

@Ashwask
Ashwask merged commit 5eb1a60 into main Aug 2, 2026
3 checks passed
@Ashwask
Ashwask deleted the homepage-catalog-counts-single-source branch August 2, 2026 08:34
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.

2 participants