{# ========================================================================= #}
{# :: Metadata #}
{# ========================================================================= #}
{#
  This section sums up some metadata about the amount of pages
  and components divided across the styleguides present in the
  current brandplatform.
#}

{# ========================================================================= #}
{# :: Imports #}
{# ========================================================================= #}
{% import "brandplatform/components/metadata.njk" as metadata %}

{# ========================================================================= #}
{# :: Settings & variables #}
{# ========================================================================= #}
{#
  The server returns the amount value to show how many atoms, molecules or
  organisms there are present. This macro loops through the different styleguides
  and adds the amount by type (atom, molecules or organism) to calculate how many
  components are build.
#}
{%- macro getAmount(type) -%}
  {% set amount = 0 %}

  {%- for key, value in STYLEGUIDES -%}
    {# STYLEGUIDES.general.atoms.amount + STYLEGUIDES.marketing.atoms.amount + ... #}
    {%- set amount = (amount + value[type].amount) -%}
  {%- endfor -%}

  {{amount | escape}}
{%- endmacro -%}

{# ========================================================================= #}
{# :: Partial #}
{# ========================================================================= #}
<div class="bp-section bp-section--padding-vertical-large">
  <div class="bp-container bp-container--small">

    {{metadata.default("", [
      {
        amount: getAmount("atoms"),
        name: "atoms"
      },
      {
        amount: getAmount("molecules"),
        name: "molecules"
      },
      {
        amount: getAmount("organisms"),
        name: "organisms"
      },
      {
        amount: getAmount("pages"),
        name: "pages"
      }
    ])}}

  </div>
</div>
