{% macro navsection(hierarchy, level, current) %} {% set sec = hierarchy | nth(n=level) %} {% 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. Au passage on note ces poids. #} {% set temoin = true %} {% set liste = [] %} {% if sec.subsections %} {% for s in sec.subsections %} {% 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.extra.weight_custom) %} {% 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.extra.weight_custom) %} {% 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 %} {% set_global liste = liste | sort %} {% for x in liste %} {% if sec.subsections %} {% for y in sec.subsections %} {% set p = get_section(path=y) %} {% if p.extra.weight_custom == x %}
{% if p.subsections or p.pages %} {% if p.path == current.path %} {{ p.title }} {% elif hierarchy is containing(y) %} ‣ {{ p.title }} {% else %} ‣ {{ p.title }} {% endif %} {% if hierarchy is containing(y) or current.path == p.path %} {% if level + 1 < maxlevel %} {% endif %} {% endif %} {% else %} {% if p.path == current.path %} {{ p.title }} {% else %} {{ p.title }} {% endif %} {% endif %}
{% endif %} {% endfor %} {% endif %} {% if sec.pages %} {% for p in sec.pages %} {% if p.extra.weight_custom == x %}
{% if p.path == current.path %} {{ p.title }} {% else %} {{ p.title }} {% endif %}
{% endif %} {% endfor %} {% endif %} {% endfor %} {% 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 %} {% 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 %} {% endmacro navsection %} {% macro navmenu(current) %} {% if current.ancestors %} {% set hierarchy = current.ancestors | slice(start=1) | concat(with=current.relative_path) %} {% else %} {% set hierarchy = [current.relative_path] %} {% endif %} {% set root_path = hierarchy | nth(n=0) %} {% set root = get_section(path=root_path) %}
{{ root.title }}
{{ nav::navsection(hierarchy=hierarchy,level=0,current=current) }} {% endmacro %}