guide.deuxfleurs.fr/templates/_nav.html

62 lines
2.2 KiB
HTML
Raw Normal View History

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 %}
{% if sec.subsections %}
{% for s in sec.subsections %}
{% set p = get_section(path=s) %}
<div class="toc-item">
2022-06-01 14:55:07 +00:00
{% 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 %}
{{ nav::navsection(hierarchy=hierarchy,level=level + 1,current=current) }}
{% endif %}
{% endif %}
2022-06-01 14:41:21 +00:00
{% else %}
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 %}
{% endif %}
</div>
{% endfor %}
{% endif %}
{% if sec.pages %}
{% for p in sec.pages %}
<div class="toc-item">
{% if p.path == current.path %}
2022-06-01 14:55:07 +00:00
<a class="subtext" href="{{p.permalink | safe}}"><b>{{ p.title }}</b></a>
2022-06-01 14:41:21 +00:00
{% else %}
2022-06-01 14:55:07 +00:00
<a class="subtext" href="{{p.permalink | safe}}">{{ p.title }}</a>
2022-06-01 14:41:21 +00:00
{% endif %}
</div>
{% endfor %}
{% endif %}
{% endmacro navsection %}
{% macro navmenu(current) %}
{% if current.ancestors %}
{% set hierarchy = current.ancestors | 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) %}
<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 %}