2022-06-01 14:41:21 +00:00
|
|
|
{% macro navsection(hierarchy, level, current) %}
|
|
|
|
{% set sec = hierarchy | nth(n=level) %}
|
|
|
|
{% set sec = get_section(path=sec) %}
|
|
|
|
{% set maxlevel = hierarchy | length %}
|
|
|
|
|
2022-09-25 14:11:47 +00:00
|
|
|
|
2022-09-25 13:19:38 +00:00
|
|
|
{# Ici on regarde si toutes les sous-sections et pages contenues ont #}
|
2022-09-25 14:11:47 +00:00
|
|
|
{# une variable weight_custom. Au passage on note ces poids. #}
|
2022-09-25 13:19:38 +00:00
|
|
|
{% set temoin = true %}
|
|
|
|
{% set liste = [] %}
|
2022-06-01 14:41:21 +00:00
|
|
|
{% if sec.subsections %}
|
|
|
|
{% for s in sec.subsections %}
|
2022-09-25 13:19:38 +00:00
|
|
|
{% set s_temp = get_section(path=s) %}
|
|
|
|
{% if not s_temp.extra.weight_custom %}
|
|
|
|
{% set_global temoin = false %}
|
|
|
|
{% else %}
|
2022-09-25 14:11:47 +00:00
|
|
|
{% set_global liste = liste | concat(with=s_temp.extra.weight_custom) %}
|
2022-09-25 13:19:38 +00:00
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% if sec.pages %}
|
|
|
|
{% for p in sec.pages %}
|
|
|
|
{% if not p.extra.weight_custom %}
|
|
|
|
{% set_global temoin = false %}
|
|
|
|
{% else %}
|
2022-09-25 14:11:47 +00:00
|
|
|
{% set_global liste = liste | concat(with=p.extra.weight_custom) %}
|
2022-09-25 13:19:38 +00:00
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
|
2022-09-25 14:11:47 +00:00
|
|
|
|
2022-09-25 13:19:38 +00:00
|
|
|
{# 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 %}
|
2022-09-25 14:11:47 +00:00
|
|
|
{% 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 %}
|
|
|
|
<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(y) %}
|
|
|
|
<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(y) 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 %}
|
|
|
|
{% 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 %}
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% if sec.pages %}
|
|
|
|
{% for p in sec.pages %}
|
|
|
|
{% if p.extra.weight_custom == x %}
|
|
|
|
<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>
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
2022-09-25 13:19:38 +00:00
|
|
|
{% 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 %}
|
2022-06-01 14:55:07 +00:00
|
|
|
{% else %}
|
2022-09-25 13:19:38 +00:00
|
|
|
{% 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>
|
2022-06-01 14:55:07 +00:00
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
2022-09-25 13:19:38 +00:00
|
|
|
</div>
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% if sec.pages %}
|
|
|
|
{% for p in sec.pages %}
|
|
|
|
<div class="toc-item">
|
2022-06-01 14:55:07 +00:00
|
|
|
{% 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>
|
2022-06-01 14:41:21 +00:00
|
|
|
{% endif %}
|
2022-09-25 13:19:38 +00:00
|
|
|
</div>
|
2022-06-01 14:41:21 +00:00
|
|
|
{% endfor %}
|
2022-09-25 13:19:38 +00:00
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
2022-06-01 14:41:21 +00:00
|
|
|
{% endmacro navsection %}
|
|
|
|
|
|
|
|
{% macro navmenu(current) %}
|
|
|
|
{% if current.ancestors %}
|
2022-06-01 14:58:35 +00:00
|
|
|
{% set hierarchy = current.ancestors | slice(start=1) | concat(with=current.relative_path) %}
|
2022-06-01 14:41:21 +00:00
|
|
|
{% else %}
|
|
|
|
{% set hierarchy = [current.relative_path] %}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% set root_path = hierarchy | nth(n=0) %}
|
|
|
|
{% set root = get_section(path=root_path) %}
|
|
|
|
<div class="toc-item toc-section">
|
|
|
|
<a class="subtext" href="{{root.permalink | safe}}">{{ root.title }}</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{{ nav::navsection(hierarchy=hierarchy,level=0,current=current) }}
|
|
|
|
{% endmacro %}
|