mirror of
https://github.com/rvtr/wiki.git
synced 2025-10-31 06:31:13 -04:00
Improve sidebar generating
This commit is contained in:
parent
e84ca7fdd8
commit
5a372c0ec0
@ -17,31 +17,42 @@ layout: compress
|
|||||||
<div class="row pt-5">
|
<div class="row pt-5">
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<div class="rounded-3 border sidebar-container mb-3 p-3">
|
<div class="rounded-3 border sidebar-container mb-3 p-3">
|
||||||
{% assign items = site[page.collection] | where: "section", page.section | sort: "category" %}
|
<!-- get category list -->
|
||||||
|
{% assign items = site[page.collection] | where: "section", page.section | sort_natural: "title" %}
|
||||||
|
{% for item in items %}
|
||||||
|
{% if item.category.first %}
|
||||||
|
{% assign list = item.category %}
|
||||||
|
{% else %}
|
||||||
|
{% assign list = item.category | split: "don't split, i just want an array. this shouldn't be in a string." %}
|
||||||
|
{% endif %}
|
||||||
|
{% assign categories = categories | concat: list %}
|
||||||
|
{% endfor %}
|
||||||
|
{% assign categories = categories | uniq | sort_natural %}
|
||||||
<ul class="list-unstyled">
|
<ul class="list-unstyled">
|
||||||
<!-- First check for index -->
|
<!-- First do the index -->
|
||||||
{% for item in items %}
|
{% for item in items %}
|
||||||
{% if item.url contains "index.html" %}
|
{% if item.url contains "index.html" %}
|
||||||
<li class="{% unless item contains category %}li-bullet{% endunless %} {% if page.title == item.title %}fw-bold{% endif %}"><a href="{{ item.url }}">{{ item.title }}</a></li>
|
<li class="{% unless item contains category %}li-bullet{% endunless %} {% if page.title == item.title %}fw-bold{% endif %}"><a href="{{ item.url }}">{{ item.title }}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<!-- Then the other pages -->
|
<!-- Then the other pages -->
|
||||||
{% for item in items %}
|
{% for cat in categories %}
|
||||||
{% unless item.url contains "index.html" %}
|
<li>
|
||||||
{% if item.category and category != item.category %}
|
<details {% if page.category contains cat %}open{% endif %}>
|
||||||
{% if category %}
|
<summary>{{ cat }}</summary>
|
||||||
</ul>
|
|
||||||
</details>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
{% assign category = item.category %}
|
|
||||||
<li>
|
|
||||||
<details {% if page.category == category %}open{% endif %}>
|
|
||||||
<summary>{{ category }}</summary>
|
|
||||||
<ul>
|
<ul>
|
||||||
{% endif %}
|
{% for item in items %}
|
||||||
<li class="{% unless item contains category %}li-bullet{% endunless %} {% if page.title == item.title %}fw-bold{% endif %}"><a href="{{ item.url }}">{{ item.title }}</a></li>
|
{% unless item.category contains cat%}
|
||||||
{% endunless %}
|
{% continue %}
|
||||||
|
{% endunless %}
|
||||||
|
{% if item.url contains "index.html" %}
|
||||||
|
{% continue %}
|
||||||
|
{% endif %}
|
||||||
|
<li class="{% if page.title == item.title %}fw-bold{% endif %}"><a href="{{ item.url }}">{{ item.title }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if category %}
|
{% if category %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user