Skip to content

fix: curated resources on topic pages and real library totals - #36

Merged
matbrgz merged 1 commit into
masterfrom
fix/resource-counts
Oct 11, 2026
Merged

matbrgz merged 1 commit into
masterfrom
fix/resource-counts

Conversation

@matbrgz

@matbrgz matbrgz commented Oct 11, 2026

Copy link
Copy Markdown
Member

The live site showed 0 curated resources on every category and subcategory page, and 13 resources in the library totals, although the data holds about 4,200 entries.

Causes

  1. Nested brackets. Liquid 4 cannot parse site.data[lang][url_parts[2]]: it reads the key url_parts[2 and returns nothing, so _layouts/topic.html never received its data. Fixed by assigning category_key, subcategory_key and rt_key first.
  2. Too shallow. components/atoms/real-resources.html walked two levels, but curated resources sit three levels down (language → category → subcategory → file). It now reads all three.

Totals

_plugins/resource_stats.rb counts unique curated resources per language once per build (site.data.resource_stats). The footer and the categories page read it, instead of walking every data file from the footer of each of ~580 pages.

Checked

Rendered in a Ruby 3.2.2 container with the project's gems:

Page Before After
/pt-BR/marketing/seo/ 0 20 resources, listed by type
/pt-BR/marketing/ 0 224
/en-US/computing/natural-language-processing/ 0 30
Library totals 13 1,921 (en-US) / 1,725 (pt-BR), unique by name

The new tests in test/build_output_test.rb cover the subcategory listing and the totals.

🤖 Generated with Claude Code

Every topic page showed "0 curated resources" and the library totals said
13. Two causes:
- Liquid 4 cannot parse nested brackets: site.data[lang][url_parts[2]] read
  the key "url_parts[2" and found nothing, so topic pages never received
  their data. The path parts and the resource type are now assigned to
  variables first.
- components/atoms/real-resources.html walked two levels, but curated
  resources live three levels down (language → category → subcategory →
  file). It now reads all three.

Library totals (footer and the categories page) come from
_plugins/resource_stats.rb, computed once per build instead of walking
every data file from the footer of each of ~580 pages.

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

Copy link
Copy Markdown

Deploying iplibrary-website with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1ab867b
Status: ✅  Deploy successful!
Preview URL: https://05cc5805.iplibrary-website.pages.dev
Branch Preview URL: https://fix-resource-counts.iplibrary-website.pages.dev

View logs

@matbrgz
matbrgz merged commit 5035ab2 into master Oct 11, 2026
10 of 13 checks passed
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