diff --git a/templates/_nav.html b/templates/_nav.html index e353681..1188b5d 100644 --- a/templates/_nav.html +++ b/templates/_nav.html @@ -3,47 +3,87 @@ {% set sec = get_section(path=sec) %} {% 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 %} {% for s in sec.subsections %} - {% set p = get_section(path=s) %} -
- {% if p.subsections or p.pages %} - {% if p.path == current.path %} - {{ p.title }} - {% elif hierarchy is containing(s) %} - ‣ {{ p.title }} + {% set s_temp = get_section(path=s) %} + {% if not s_temp.extra.weight_custom %} + {% set_global temoin = false %} + {% else %} + {% set_global liste = liste | concat(with=s_temp) %} + {% endif %} + {% 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) %} +
+ {% if p.subsections or p.pages %} + {% if p.path == current.path %} + {{ p.title }} + {% elif hierarchy is containing(s) %} + ‣ {{ p.title }} + {% else %} + ‣ {{ p.title }} + {% endif %} + {% if hierarchy is containing(s) or current.path == p.path %} + {% if level + 1 < maxlevel %} + + {% endif %} + {% endif %} {% else %} - ‣ {{ p.title }} - {% endif %} - {% if hierarchy is containing(s) or current.path == p.path %} - {% if level + 1 < maxlevel %} - + {% if p.path == current.path %} + {{ p.title }} + {% else %} + {{ p.title }} {% endif %} {% endif %} - {% else %} +
+ {% endfor %} + {% endif %} + + {% if sec.pages %} + {% for p in sec.pages %} +
{% if p.path == current.path %} {{ p.title }} {% else %} {{ p.title }} {% endif %} - {% endif %} -
+
{% endfor %} - {% endif %} - - {% if sec.pages %} - {% for p in sec.pages %} -
- {% if p.path == current.path %} - {{ p.title }} - {% else %} - {{ p.title }} - {% endif %} -
- {% endfor %} - {% endif %} + {% endif %} + {% endif %} {% endmacro navsection %} {% macro navmenu(current) %}