aboutsummaryrefslogtreecommitdiff
path: root/templates/_nav.html
diff options
context:
space:
mode:
Diffstat (limited to 'templates/_nav.html')
-rw-r--r--templates/_nav.html28
1 files changed, 14 insertions, 14 deletions
diff --git a/templates/_nav.html b/templates/_nav.html
index b183a57..0ab8ac7 100644
--- a/templates/_nav.html
+++ b/templates/_nav.html
@@ -10,6 +10,7 @@
{% endmacro %}
{# -------------------------- #}
+{# -------------------------- #}
{# (Private) Shared+root logic to build the menu #}
{% macro inner_nav(root, current) %}
@@ -34,7 +35,7 @@
{% endif %}
{% endmacro %}
-{# On small screens, like a smartphone, hide the menu behind an hamburger icon #}
+{# (Private) On small screens, like a smartphone, hide the menu behind an hamburger icon #}
{% macro hamburger(root) %}
<input id="menu-toggle" type="checkbox" />
<label class='menu-button-container' for="menu-toggle">
@@ -43,10 +44,11 @@
</label>
{% endmacro %}
-{# Build a breadcrumb for the page #}
+{# (Private) Build a breadcrumb for the page #}
{# It's ugly because this is the hacky part of the project #}
{% macro breadcrumb(corpus, root, target) %}{% if 'parent' in target.extra and target.extra.parent != root %}{% set new_target = get_page(path=target.extra.parent) %}{{ nav::breadcrumb(corpus=corpus, root=root, target=new_target) }}:{{ new_target.relative_path }}{% endif %}{% endmacro %}
+{# (Private) Render a list menu (this is the simple fallback when extra.parent is not defined #}
{% macro list(list, selected) %}
{% for page in list %}
{% set is_selected = page.relative_path == selected.relative_path %}
@@ -56,26 +58,27 @@
{% endfor %}
{% endmacro %}
-{# Tree menu rendering #}
+{# (Private) Tree menu rendering; this function is recursive #}
+{# this function takes a breadcrumb to know which part of the menu must be unfolded #}
{% macro tree(tree, cursor, selected, crumb) %}
{% for page in tree | get(key=cursor) %}
{% set is_selected = page.relative_path == selected.relative_path %}
<div class="toc-item">
- {# LINK WITH SUBSECTION #}
+ {# Link with a (possible) subsection #}
{% if page.relative_path in tree %}
+ {# Display link as a section #}
{{ nav::link(page=page, is_selected=is_selected, is_parent=true) }}
+
+ {# Should we unroll this part of the tree? #}
{% if page.relative_path in crumb or is_selected %}
<div class="nav-subsection">
- {% set ncrumb = crumb | slice(start=1) %}
- {% set ncursor = page.relative_path %}
- {% if ncursor in tree %}
- {{ nav::tree(tree=tree, cursor=ncursor, selected=selected, crumb=ncrumb) }}
- {% endif %}
+ {# do the recursive call #}
+ {{ nav::tree(tree=tree, cursor=page.relative_path, selected=selected, crumb=crumb) }}
</div>
{% endif %}
- {# SIMPLE LINK #}
+ {# Simple link, ie. a leaf of the tree #}
{% else %}
{{ nav::link(page=page, is_selected=is_selected, is_parent=false) }}
{% endif %}
@@ -83,10 +86,7 @@
{% endfor %}
{% endmacro %}
-{% macro subsection() %}
-
-{% endmacro %}
-
+{# (Private) Render a single link #}
{% macro link(page, is_selected, is_parent) %}
<a class="subtext" href="{{page.permalink | safe}}">
{% if is_selected %}<b>{% endif %}