---
layout: page
---
{{ content }}

{% if page.collection and page.collection.size > 0 %}
  {% assign collection = site[page.collection] %}
  {% if collection and collection.size > 0 %}
    {% for item in collection reversed %}
      {% assign current_year = item.date | date: '%Y' %}
      {% if current_year != year %}
        {% unless forloop.first %}
          </ul>
        {% endunless %}
        <h1 id="y{{item.date | date: "%Y"}}">
          <a href="{{ current_year | prepend: '/books/' | relative_url }}">{{ current_year }}</a>
        </h1>
        <ul>
          {% assign year = current_year %}
      {% endif %}

      <figure class="cover">
        <a class="cover-link" href="{{ item.url | relative_url }}">
          {% if item.cover %}
            <img alt="{{ item.title }} cover" src="{{ item.cover | prepend: page.covers | relative_url }}" style="height:200px">
          {% elsif item.olid %}
            <img alt="{{ item.title }} cover" src="http://covers.openlibrary.org/b/olid/{{ item.olid }}-L.jpg?default=false" style="height:200px">
          {% elsif item.isbn %}
            <img alt="{{ item.title }} cover" src="http://covers.openlibrary.org/b/isbn/{{ item.isbn }}-L.jpg?default=false" style="height:200px">
          {% endif %}
          {% if item.status %}
            {% assign statuses = 'abandoned,finished,interested,paused,queued,reading,reread' | split: ',' %}
            {% assign status = item.status | downcase | strip %}
            {% if statuses contains status %}
              <figcaption class="{{ status | downcase }}">{{ status | upcase }}</figcaption>
            {% else %}
              <figcaption class="uncategorized">UNCATEGORIZED</figcaption>
            {% endif %}
          {% else %}
            <figcaption class="uncategorized">UNCATEGORIZED</figcaption>
          {% endif %}
        </a>
      </figure>
      {% if forloop.last %}
        </ul>
      {% endif %}
    {% endfor %}
  {% endif %}
{% endif %}
