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 -%}