From 1ab867bd116e97c4f0d2977d5014c2916b8dca63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matheus=20Bregu=C3=AAz?= Date: Sun, 11 Oct 2026 19:42:44 -0300 Subject: [PATCH] fix: show curated resources on topic pages and real library totals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../components/atoms/real-resources.html | 21 +++++++++---- _includes/components/organisms/footer.html | 4 +-- _layouts/categories.html | 4 +-- _layouts/topic.html | 15 +++++---- _plugins/resource_stats.rb | 31 +++++++++++++++++++ test/build_output_test.rb | 18 +++++++++++ 6 files changed, 74 insertions(+), 19 deletions(-) create mode 100644 _plugins/resource_stats.rb diff --git a/_includes/components/atoms/real-resources.html b/_includes/components/atoms/real-resources.html index 6f6cd21..b121746 100644 --- a/_includes/components/atoms/real-resources.html +++ b/_includes/components/atoms/real-resources.html @@ -3,16 +3,25 @@ placeholders (example.com) and keeping one entry per resource name. Usage: {% assign topic_data = site.data[page.lang][page.data_folder] %}{% include components/atoms/real-resources.html node=topic_data %} Sets: real_resources (array of {name, url, description, …}), real_resource_total (number) -Accepts a node whose values are resource lists (category files) or folders of lists (subcategories). +Accepts a subcategory (type → list), a category (files and subcategory folders) or a whole language. {%- endcomment -%} +{%- comment -%} Up to three levels: lists of resources, files (type → list), and folders (subcategory → files). {%- endcomment -%} {%- assign real_collected = '' | split: '' -%} {%- for entry in include.node -%} - {%- assign entry_value = entry[1] -%} - {%- if entry_value.first.url or entry_value.first.name -%} - {%- for r in entry_value -%}{%- if r.url -%}{%- unless r.url contains 'example.com' -%}{%- assign real_collected = real_collected | push: r -%}{%- endunless -%}{%- endif -%}{%- endfor -%} + {%- assign level1 = entry[1] -%} + {%- if level1.first.url or level1.first.name -%} + {%- for r in level1 -%}{%- if r.url -%}{%- unless r.url contains 'example.com' -%}{%- assign real_collected = real_collected | push: r -%}{%- endunless -%}{%- endif -%}{%- endfor -%} {%- else -%} - {%- for file in entry_value -%} - {%- if file[1].first.url -%}{%- for r in file[1] -%}{%- if r.url -%}{%- unless r.url contains 'example.com' -%}{%- assign real_collected = real_collected | push: r -%}{%- endunless -%}{%- endif -%}{%- endfor -%}{%- endif -%} + {%- for child in level1 -%} + {%- assign level2 = child[1] -%} + {%- if level2.first.url or level2.first.name -%} + {%- for r in level2 -%}{%- if r.url -%}{%- unless r.url contains 'example.com' -%}{%- assign real_collected = real_collected | push: r -%}{%- endunless -%}{%- endif -%}{%- endfor -%} + {%- else -%} + {%- for file in level2 -%} + {%- assign level3 = file[1] -%} + {%- if level3.first.url -%}{%- for r in level3 -%}{%- if r.url -%}{%- unless r.url contains 'example.com' -%}{%- assign real_collected = real_collected | push: r -%}{%- endunless -%}{%- endif -%}{%- endfor -%}{%- endif -%} + {%- endfor -%} + {%- endif -%} {%- endfor -%} {%- endif -%} {%- endfor -%} diff --git a/_includes/components/organisms/footer.html b/_includes/components/organisms/footer.html index aee9985..dd25789 100644 --- a/_includes/components/organisms/footer.html +++ b/_includes/components/organisms/footer.html @@ -9,8 +9,8 @@ {%- assign footer_menu = site.data[footer_lang].menu -%} {%- assign footer_subcategories = 0 -%}{%- assign footer_sections = 0 -%} {%- for category in footer_menu -%}{%- assign footer_subcategories = footer_subcategories | plus: category.children.size -%}{%- for subcategory in category.children -%}{%- assign footer_sections = footer_sections | plus: subcategory.children.size -%}{%- endfor -%}{%- endfor -%} -{%- assign footer_data = site.data[footer_lang] -%}{%- include components/atoms/real-resources.html node=footer_data -%} -{%- assign footer_resources = real_resource_total -%} +{%- comment -%} Computed once per build by _plugins/resource_stats.rb. {%- endcomment -%} +{%- assign footer_resources = site.data.resource_stats[footer_lang].resources | default: 0 -%}