fix(nav): arborescence qui fonctionn
This commit is contained in:
parent
6ccbc878b6
commit
1f6d305a07
1 changed files with 19 additions and 8 deletions
|
@ -26,7 +26,7 @@
|
|||
{# Choose between "tree" (has extra.parent) and "list" (default) collections #}
|
||||
{% set root_tree = root.pages | group_by(attribute="extra.parent") %}
|
||||
{% if root.relative_path in root_tree %}
|
||||
{% set tree_breadcrumb = nav::breadcrumb(corpus=root.pages, root=root.relative_path, target=current)|split(pat=":")|slice(start=1) %}
|
||||
{% set tree_breadcrumb = nav::breadcrumb(corpus=root.pages, root=root.relative_path, target=current)|trim|split(pat=":")|slice(start=1) %}
|
||||
{{ nav::tree(
|
||||
tree=root_tree,
|
||||
cursor=root.relative_path,
|
||||
|
@ -51,7 +51,7 @@
|
|||
{% 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 }}
|
||||
{{ nav::breadcrumb(corpus=corpus, root=root, target=new_target) | trim }}:{{ new_target.relative_path }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
@ -60,7 +60,7 @@
|
|||
{% for page in list %}
|
||||
{% set is_selected = page.relative_path == selected.relative_path %}
|
||||
<div class="toc-item">
|
||||
{{ nav::link(page=page, is_selected=is_selected, is_parent=false) }}
|
||||
{{ nav::link(page=page, is_selected=is_selected, is_parent=false, is_developed=false) }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
@ -70,15 +70,25 @@
|
|||
{% macro tree(tree, cursor, selected, crumb) %}
|
||||
{% for page in tree | get(key=cursor) %}
|
||||
{% set is_selected = page.relative_path == selected.relative_path %}
|
||||
{# {% set is_parent = (page.relative_path == selected.extra.parent) or page.relative_path in crumb %} #}
|
||||
{% set is_parent = page.relative_path in crumb %}
|
||||
<div class="toc-item">
|
||||
{# DEBUG #}
|
||||
<!-- crumb: {% for p in crumb %} '{{ p }}' {% endfor %} -->
|
||||
<!-- relative_path: {{ page.relative_path }} -->
|
||||
<!-- parent: {{ page.extra.parent }} -->
|
||||
<!-- ancestors: {{ page.ancestors }} -->
|
||||
<!-- is_selected: {{ is_selected }} -->
|
||||
<!-- is_parent: {{ is_parent }} -->
|
||||
<!-- {{ page.relative_path in crumb }} -->
|
||||
|
||||
{# 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) }}
|
||||
{{ nav::link(page=page, is_selected=is_selected, is_parent=true, is_developed=is_selected or is_parent) }}
|
||||
|
||||
{# Should we unroll this part of the tree? #}
|
||||
{% if page.relative_path in crumb or is_selected %}
|
||||
{% if is_selected or is_parent %}
|
||||
<div class="nav-subsection">
|
||||
{# do the recursive call #}
|
||||
{{ nav::tree(tree=tree, cursor=page.relative_path, selected=selected, crumb=crumb) }}
|
||||
|
@ -87,17 +97,18 @@
|
|||
|
||||
{# Simple link, ie. a leaf of the tree #}
|
||||
{% else %}
|
||||
{{ nav::link(page=page, is_selected=is_selected, is_parent=false) }}
|
||||
{{ nav::link(page=page, is_selected=is_selected, is_parent=false, is_developed=false) }}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
{# (Private) Render a single link #}
|
||||
{% macro link(page, is_selected, is_parent) %}
|
||||
{% macro link(page, is_selected, is_parent, is_developed) %}
|
||||
<a class="subtext" href="{{page.permalink | safe}}">
|
||||
{% if is_selected %}<b>{% endif %}
|
||||
{% if is_parent %}‣ {% endif %}
|
||||
{% if is_parent and not is_developed %}▸ {% endif %}
|
||||
{% if is_parent and is_developed %}▾ {% endif %}
|
||||
{{ page.title }}
|
||||
{% if is_selected %}</b>{% endif %}
|
||||
</a>
|
||||
|
|
Loading…
Add table
Reference in a new issue