Navigation mit 2 Ebenen generiert aus Databag hinzugefügt.

This commit is contained in:
Stephan 2020-12-23 13:34:10 +01:00
parent 0a94a0fba4
commit 368e28bdfd
2 changed files with 48 additions and 11 deletions

26
databags/navigation.json Normal file
View File

@ -0,0 +1,26 @@
{
"home": {
"href": "/",
"items": {}
},
"about": {
"href": "/about",
"items": {}
},
"specs": {
"href": "/specs",
"list_childs": true,
"items": {
"members": "/members",
"lines of code": "/lines_of_code"
}
},
"mission": {
"href": "/faq",
"items": {}
},
"legal": {
"href": "/member",
"items": {}
}
}

View File

@ -42,17 +42,28 @@
</div>
<ul class="nav__navlist">
<li class="nav__navitem {% if this._path == '/' %}-active{% endif %}">
<a class="nav__navlink {% if this._path == '/' %}-active{% endif %}" href="{{ '/'|url }}">home</a>
</li>
{% for href, title in [
['/about', 'about'],
['/specs', 'specs'],
['/legal', 'legal']
]
%}
<li class="nav__navitem {% if this.is_child_of(href) %}-active{% endif %}">
<a class="nav__navlink {% if this.is_child_of(href) %}-active{% endif %}" href="{{ href|url }}">{{ title }}</a></li>
{% for title, mapping in bag("navigation").items() %}
<li class="nav__navitem
{%- if this._path == mapping.href or mapping.href != '/' and this.is_child_of(mapping.href) %}
-active
{%- endif -%}
">
<a class="nav__navlink {% if this._path == mapping.href %}-active{% endif %}" href="{{ mapping.href|url }}">
{{ title }}
</a>
{% if mapping.list_childs %}
<ul class="nav__sub_navlist">
{% set sub_menu = mapping['items'].items() %}
{% for sub_title, href in sub_menu %}
<li class="nav__sub_navitem {%- if this._path == href %} -active{%- endif %}">
<a class="nav__navlink {% if this._path == href %}-active{% endif %}" href="{{ href|url }}">
{{ sub_title }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
</ul>
</nav>