{% include_template "_books" %}
<div class="content">
  {%- if is_category or is_tag %}
    <h1 class="index-title">{{ page_title }}</h1>
    {%- if is_category %}
      {%- assign cat = categories | where: "slug", slug | first -%}
      {%- if cat.description %}<h2 class="index-title">{{ cat.description.value }}</h2>{% endif -%}
    {%- endif %}
  {%- endif %}
  {% for post in model.posts %}
    <article class="item">
      <h1 class="item-heading">
        <a href="{{ post.permalink | relative_link }}"
           title="Permanent Link to &ldquo;{{ post.title | strip_html | escape_once }}&rdquo;">
          {{ post.title }}
        </a>
      </h1>
      <p class="item-meta">
        <i class="fa fa-calendar" title="Date"></i> {{ post.published_on | date: "dddd, MMMM d, yyyy" }}
        {% if logged_on %} &bull; <a href="{{ post | edit_post_link }}">Edit Post</a>{% endif %}
      </p>
      {%- assign media = post.metadata | value: "episode_media_file" -%}
      {%- unless media == "-- episode_media_file not found --"  %}
        <aside class="podcast">
          <p class="text-center"><strong>Listen While<br>You Read</strong></p>
          <audio controls onplaying="awftw.countPlay('{{ media }}')">
            <source src="https://files.bitbadger.solutions/devotions/{{ media }}">
          </audio>
          <p class="text-center">
            <a class="dl" href="https://pdcst.click/c/awftw/files.bitbadger.solutions/devotions/{{ media }}" download>
              <i class="fa fa-download" title="Download Audio"></i>
            </a>
          </p>
        </aside>
      {%- endunless %}
      {{ post.text }}
    </article>
  {% endfor %}
  <nav aria-label="pagination">
    <div>{% if model.newer_link %}<a href="{{ model.newer_link.value }}">&#xab; Newer Posts</a>{% endif %}</div>
    <div>{% if model.older_link %}<a href="{{ model.older_link.value }}">Older Posts &#xbb;</a>{% endif %}</div>
  </nav>
</div>
<div class="sidebar">
  <div class="item">
    <h4 class="item-heading">Author</h4>
    <p>Daniel is a man who wants to be used of God however He sees fit.</p>
    <hr class="sidebar-sep">
    <ul>
      <li><a href="https://daniel.summershome.org/my-testimony">Daniel&rsquo;s Testimony</a></li>
      <li><a href="{{ "2007/about-daniels-weekly-devotions.html" | relative_link }}">About This Site</a></li>
    </ul>
  </div>
  <div class="item">
    <h4 class="item-heading">Series</h4>
    {%- for series in series_details %}
      {% assign parts = series | split: "," %}
      {% assign cat = categories | where: "id", parts[0] | first %}
      <h4 class="text-center">{{ cat.name }}</h4>
      <p class="text-center">
        <a href="{{ parts[2] | relative_link }}"
           title="About the series &ldquo;{{ cat.name | escape_once }}&rdquo; &bull; A Word from the Word">
          About the Series
        </a> &bull;
        <a href="{{ cat | category_link }}">Read All</a> <small class="count">({{ cat.post_count }})</small>
      </p>
      {% unless forloop.last %}<hr class="sidebar-sep">{% endunless %}
    {% endfor %}
  </div>
  <div class="item">
    <h4 class="item-heading">Books</h4>
    <p>Each devotion is categorized under the books of the Bible which are referenced within it.</p>
    <hr class="sidebar-sep">
    <h4 class="text-center">Old Testament</h4>
    <p class="text-center">
      {%- assign cat_id = ot_books | first -%}
      {%- assign cat = categories | where: "id", cat_id | first -%}
      <a href="{{ cat | category_link }}"
         {%- if cat.description %} title="{{ cat.description.value | escape_once }}"{% endif %}>
        See All
      </a> <small class="count">({{ cat.post_count }})</small>
    </p>
    <ul>
      {%- assign first_time = true -%}
      {% for cat_id in ot_books -%}
        {%- if first_time -%}
          {%- assign first_time = false -%}
        {%- else %}
          {%- assign cat = categories | where: "id", cat_id | first -%}
          <li>
            {% if cat.post_count == 0 -%}
              <span{% if cat.description %} title="{{ cat.description.value | escape_once }}"{% endif %}>
                {{ cat.name }}
              </span> <small class="count">(0)</small>
            {%- else -%}
              <a href="{{ cat | category_link }}"
                 {%- if cat.description %} title="{{ cat.description.value | escape_once }}"{% endif %}>
                {{ cat.name }}
              </a> <small class="count">({{ cat.post_count }})</small>
            {%- endif %}
          </li>
        {%- endif %}
      {%- endfor %}
    </ul>
    <hr class="sidebar-sep">
    <h4 class="text-center">New Testament</h4>
    <p class="text-center">
      {%- assign cat_id = nt_books | first -%}
      {%- assign cat = categories | where: "id", cat_id | first -%}
      <a href="{{ cat | category_link }}"
         {%- if cat.description %} title="{{ cat.description.value | escape_once }}"{% endif %}>
        See All
      </a> <small class="count">({{ cat.post_count }})</small>
    </p>
    <ul>
      {%- assign first_time = true -%}
      {%- for cat_id in nt_books -%}
        {%- if first_time -%}
          {%- assign first_time = false -%}
        {%- else %}
          {%- assign cat = categories | where: "id", cat_id | first -%}
          <li>
            {% if cat.post_count == 0 -%}
              <span{% if cat.description %} title="{{ cat.description.value | escape_once }}"{% endif %}>
                {{ cat.name }}
              </span> <small class="count">(0)</small>
            {%- else -%}
              <a href="{{ cat | category_link }}"
              {%- if cat.description %} title="{{ cat.description.value | escape_once }}"{% endif %}>
                {{ cat.name }}
              </a> <small class="count">({{ cat.post_count }})</small>
            {%- endif %}
          </li>
        {% endif %}
      {% endfor %}
    </ul>
  </div>
  <div class="item">
    <h4 class="item-heading">Topics</h4>
    <ul>
      {%- for cat in categories -%}
        {%- unless ot_books contains cat.id or nt_books contains cat.id or series_ids contains cat.id -%}
          <li>
            {%- for it in cat.parent_names %} &nbsp; {% endfor -%}
            <a href="{{ cat | category_link }}"
               {%- if cat.description %} title="{{ cat.description.value | escape_once }}"{% endif %}>
              {{ cat.name }}
            </a> <small class="count">({{ cat.post_count }})</small>
          </li>
        {% endunless %}
      {% endfor %}
    </ul>
  </div>
</div>
