Homepage catalogue counts derive from single source of truth - #17
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The homepage showed four "Projects" numbers from three different places, and they had drifted apart:
#statProjects)catalogProjects.length#catalogCount)catalog/catalog-data.js)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
/catalog/catalog-data.json the homepage and derivecatalogProjectsfromwindow.CATALOG_PROJECTS— the same single source of truth the catalogue page and admin already use.id -> imagelookup for showcase visuals, with a theme-icon fallback for entries without a curated image (e.g. new projects 52 & 53).#catalogCountand#statProjectsfromcatalogProjects.lengthup front (no network dependency).48with a-placeholder, consistent with the stats bar — no count baked into markup.Now all catalogue counts track
catalog-data.jsautomatically.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
climateImpactflag tocatalog-data.jsin a follow-up if we want this derived too.Verification
Ran the page in headless Chrome against a local server:
#catalogCount→ 53,#statProjects→ 53 (match source length)No i18n text changed, so no locale updates needed.
🤖 Generated with Claude Code