---
layout: archive
---

{{ content }}

{% assign stay_on_top = site.stay_on_top_categories %}

{% assign categories_max = 0 %}
{% for category in site.categories %}
  {% if category[1].size > categories_max %}
    {% assign categories_max = category[1].size %}
  {% endif %}
{% endfor %}

<img src="/assets/images/top.jpg">

<h3>カテゴリ一覧</h3>

<ul class="taxonomy__index">
  {% comment %} Iterate the Stay-on-Top list and all categories and render matched categories {% endcomment %}

  {% for category in site.categories %}
    {% for stay in stay_on_top %}
      <!--<p>category[0] = `{{ category[0]}}`, stay = `{{ stay }}`</p>-->
      {% if category[0] == stay %}
        <li>
          <!-- Stay on top -->
          <a href="#{{ category[0] | slugify }}">
            <strong>{{ category[0] }}</strong>
          </a>
        </li>
      {% endif %}
    {% endfor %}
  {% endfor %}

  {% comment %} Iterate the Stay-on-Top list and all categories and render unmatched categories {% endcomment %}

  {% for category in site.categories %}
    {% assign skip = false %}
    {% for stay in stay_on_top %}
      {% if category[0] == stay %}
        {% assign skip = true %}
      {% endif %}
    {% endfor %}
    {% if skip %}
      {% continue %}
    {% endif %}
    <li>
      <a href="#{{ category[0] | slugify }}">
        <strong>{{ category[0] }}</strong> <span class="taxonomy__count">{{ i }}</span>
      </a>
    </li>
  {% endfor %}
</ul>

{% assign entries_layout = page.entries_layout | default: 'list' %}
{% for category in site.categories %}
  {% for stay in stay_on_top %}
    {% if category[0] == stay %}
      <section id="{{ category[0] | slugify | downcase }}" class="taxonomy__section">
        <h2 class="archive__subtitle">{{ category[0] }}</h2>
        <div class="entries-{{ entries_layout }}">
          {% for post in category.last %}
            {% include archive-single.html type=entries_layout %}
          {% endfor %}
        </div>
        <a href="#page-title" class="back-to-top">{{ site.data.ui-text[site.locale].back_to_top | default: 'Back to Top' }} &uarr;</a>
      </section>
    {% endif %}
  {% endfor %}
{% endfor %}

{% for category in site.categories %}
  {% assign skip = false %}
  {% for stay in stay_on_top %}
    {% if category[0] == stay %}
      {% assign skip = true %}
    {% endif %}
  {% endfor %}
  {% if skip %}
    {% continue %}
  {% endif %}
  <section id="{{ category[0] | slugify | downcase }}" class="taxonomy__section">
    <h2 class="archive__subtitle">{{ category[0] }}</h2>
    <div class="entries-{{ entries_layout }}">
      {% for post in category.last %}
        {% include archive-single.html type=entries_layout %}
      {% endfor %}
    </div>
    <a href="#page-title" class="back-to-top">{{ site.data.ui-text[site.locale].back_to_top | default: 'Back to Top' }} &uarr;</a>
  </section>
{% endfor %}