Automatically Hide empty collections in navigation on Shopify Impulse Theme

I would like to automatically hide empty collections in Shopify Impluse theme.

Here is the code, but I can’t work out how get the amount of products in the collection

{%- for grandchildlink in childlink.links -%}  
                    
                      
                        {{grandchildlink.title}}
                      
                    

                  {%- endfor -%}
                {%- endfor -%}
{% if collection.products.size == 0 %}  {% assign collection_url = '' %} {% else %}  {% assign collection_url = '/collections/' | append: collection.handle | append: '?view=all' | prepend: shopify_domain %} {% endif %>  <a href="{{collection_url}}">View all {{collection.title}}</a>

Should look something like this.