Feat: toctree based on categories
This commit is contained in:
@@ -86,7 +86,9 @@
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
{% if TOCTREE %}
|
||||
{% include "partial/toctree.html" %}
|
||||
{% endif %}
|
||||
|
||||
{% if pages or LINKS%}
|
||||
<ul class="list">
|
||||
@@ -104,6 +106,7 @@
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
</nav>
|
||||
</aside>
|
||||
<main>
|
||||
|
@@ -1,34 +1,21 @@
|
||||
{% macro toc(root) %}
|
||||
<ul class="toctree">
|
||||
{% for child in root.children %}
|
||||
{% if child == article or child in article.parents%}
|
||||
<li class="toctree-l1 current"><a href="{{ SITEURL }}/{{ child.url }}">{{ child.title }}</a>
|
||||
{% if child.children %}
|
||||
<ul>
|
||||
{% for c in child.children %}
|
||||
{% if c == article %}
|
||||
<li class="toctree-l2 current"><span href="{{ SITEURL }}/{{ c.url }}">{{ c.title }}</span></li>
|
||||
{% else %}
|
||||
<li class="toctree-l2"><a href="{{ SITEURL }}/{{ c.url }}">{{ c.title }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% for cat, articles in categories|sort %}
|
||||
{% if article and article.category == cat %}
|
||||
<li class="toctree-l1 current"><a href="{{ SITEURL }}/{{ cat.url }}">{{ cat | capitalize }}</a>
|
||||
<ul>
|
||||
{% for art in articles | sort(attribute="date") %}
|
||||
{% if article == art %}
|
||||
<li class="toctree-l2 current"><span>{{ art.title }}</span></li>
|
||||
{% else %}
|
||||
<li class="toctree-l1"><a href="{{ SITEURL }}/{{ child.url }}">{{ child.title }}</a></li>
|
||||
<li class="toctree-l2"><a href="{{ SITEURL }}/{{ art.url }}">{{ art.title }}</a></li>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="toctree-l1"><a href="{{ SITEURL }}/{{ cat.url }}">{{ cat | capitalize }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% if 'pelican-page-hierarchy' in PLUGINS and TOCTREE %}
|
||||
{% if article and article.parents %}
|
||||
{{ toc(article.parents[0]) }}
|
||||
{% elif article and not article.parent %}
|
||||
{{ toc(article) }}
|
||||
{% else %}
|
||||
<p> Le menu s'est perdu </p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
Reference in New Issue
Block a user