Move all posts into collections and update Liquid templates

This commit is contained in:
Takumi Sueda
2022-12-12 22:13:06 +09:00
parent dd5047c282
commit 9927d52aeb
21 changed files with 156 additions and 99 deletions

View File

@@ -4,88 +4,50 @@ 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 %}
{% for label in site.collections_order %}
{% assign collection = site.collections | where: "label", label | first %}
<li>
<a href="#{{ category[0] | slugify }}">
<strong>{{ category[0] }}</strong> <span class="taxonomy__count">{{ i }}</span>
<a href="#{{ collection.label | slugify | downcase }}">
<strong>{{ collection.name }}</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>
{% for label in site.collections_order %}
{% assign collection = site.collections | where: "label", label | first %}
<section id="{{ collection.label | slugify | downcase }}" class="taxonomy__section">
<h2 class="archive__subtitle">{{ collection.name }}</h2>
<div class="entries-{{ entries_layout }}">
{% for post in category.last %}
{% include archive-single.html type=entries_layout %}
{% comment %} First, render ordered pages {% endcomment %}
{% assign ordered_post = "" | split: "" %}
{% if collection.order %}
{% for file in collection.order %}
{% assign docpath = "_" | append: collection.label | append: "/" | append: file %}
{% assign post = collection.docs | where: "path", docpath | first %}
{% if post %}
{% include archive-single.html type=entries_layout %}
{% assign ordered_post = ordered_post | push: docpath %}
{% else %}
<p style="color: #ff0000; font-weight: bolder">{{docpath}} not found!</p>
{% endif %}
{% endfor %}
{% endif %}
{% comment %} Second, render pages not listed in the order array {% endcomment %}
{% for post in collection.docs %}
{% assign already_rendered = ordered_post | where_exp: "path", "path == post.path" | size %}
{% if already_rendered == 0 %}
{% include archive-single.html type=entries_layout %}
{% endif %}
{% 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>