{%- if include.keys -%}
  {%- assign keys = include.keys -%}
{%- endif -%}

{%- if include.field -%}
  {%- assign field = include.field -%}
{%- endif -%}

<div class="page-segments">
  <ul class="page-segments-list">
    {% for key in keys %}
    <h2 id="{{ key }}" class="segment-name">{{ key }}</h2>
      {% assign items = site.posts | where: field, key %}
      {% for item in items %}
        {% if item != nil %}
          {%- assign post_item_class = "" -%}
          {%- if item.top -%}
            {%- assign post_item_class = "top-post" -%}
          {%- endif -%}
          <li class="{{ post_item_class }}">
            {%- include views/post-item.html -%}
          </li>
        {% endif %}
      {% endfor %}
    {% endfor %}
  </ul>
</div>
