Gestion des poids propres

This commit is contained in:
vincent 2022-09-25 15:19:38 +02:00
parent dfa89254a9
commit f8b5a2e1ba

View file

@ -3,47 +3,87 @@
{% set sec = get_section(path=sec) %} {% set sec = get_section(path=sec) %}
{% set maxlevel = hierarchy | length %} {% set maxlevel = hierarchy | length %}
{# Ici on regarde si toutes les sous-sections et pages contenues ont #}
{# une variable weight_custom #}
{% set temoin = true %}
{% set liste = [] %}
{% if sec.subsections %} {% if sec.subsections %}
{% for s in sec.subsections %} {% for s in sec.subsections %}
{% set p = get_section(path=s) %} {% set s_temp = get_section(path=s) %}
<div class="toc-item"> {% if not s_temp.extra.weight_custom %}
{% if p.subsections or p.pages %} {% set_global temoin = false %}
{% if p.path == current.path %} {% else %}
<a class="subtext" href="{{ p.permalink | safe}}"><b>{{ p.title }}</b></a> {% set_global liste = liste | concat(with=s_temp) %}
{% elif hierarchy is containing(s) %} {% endif %}
<a class="subtext" href="{{ p.permalink | safe}}">‣ {{ p.title }}</a> {% endfor %}
{% endif %}
{% if sec.pages %}
{% for p in sec.pages %}
{% if not p.extra.weight_custom %}
{% set_global temoin = false %}
{% else %}
{% set_global liste = liste | concat(with=p) %}
{% endif %}
{% endfor %}
{% endif %}
{# Si toutes les sous-sections et pages ont une variable weight_custom, #}
{# on classe selon elle. Sinon, on utilise la méthode classique. #}
{% if temoin %}
// classer ici
{% else %}
{% if sec.subsections %}
{% for s in sec.subsections %}
{% set p = get_section(path=s) %}
<div class="toc-item">
{% if p.subsections or p.pages %}
{% if p.path == current.path %}
<a class="subtext" href="{{ p.permalink | safe}}"><b>{{ p.title }}</b></a>
{% elif hierarchy is containing(s) %}
<a class="subtext" href="{{ p.permalink | safe}}">‣ {{ p.title }}</a>
{% else %}
<a class="subtext" href="{{ p.permalink | safe}}">‣ {{ p.title }}</a>
{% endif %}
{% if hierarchy is containing(s) or current.path == p.path %}
{% if level + 1 < maxlevel %}
<div class="nav-subsection">
{{ nav::navsection(hierarchy=hierarchy,level=level + 1,current=current) }}
</div>
{% endif %}
{% endif %}
{% else %} {% else %}
<a class="subtext" href="{{ p.permalink | safe}}">‣ {{ p.title }}</a> {% if p.path == current.path %}
{% endif %} <a class="subtext" href="{{p.permalink | safe}}"><b>{{ p.title }}</b></a>
{% if hierarchy is containing(s) or current.path == p.path %} {% else %}
{% if level + 1 < maxlevel %} <a class="subtext" href="{{p.permalink | safe}}">{{ p.title }}</a>
<div class="nav-subsection">
{{ nav::navsection(hierarchy=hierarchy,level=level + 1,current=current) }}
</div>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% else %} </div>
{% endfor %}
{% endif %}
{% if sec.pages %}
{% for p in sec.pages %}
<div class="toc-item">
{% if p.path == current.path %} {% if p.path == current.path %}
<a class="subtext" href="{{p.permalink | safe}}"><b>{{ p.title }}</b></a> <a class="subtext" href="{{p.permalink | safe}}"><b>{{ p.title }}</b></a>
{% else %} {% else %}
<a class="subtext" href="{{p.permalink | safe}}">{{ p.title }}</a> <a class="subtext" href="{{p.permalink | safe}}">{{ p.title }}</a>
{% endif %} {% endif %}
{% endif %} </div>
</div>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endif %}
{% if sec.pages %}
{% for p in sec.pages %}
<div class="toc-item">
{% if p.path == current.path %}
<a class="subtext" href="{{p.permalink | safe}}"><b>{{ p.title }}</b></a>
{% else %}
<a class="subtext" href="{{p.permalink | safe}}">{{ p.title }}</a>
{% endif %}
</div>
{% endfor %}
{% endif %}
{% endmacro navsection %} {% endmacro navsection %}
{% macro navmenu(current) %} {% macro navmenu(current) %}