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> </div>
<ul class="nav__navlist"> <ul class="nav__navlist">
<li class="nav__navitem {% if this._path == '/' %}-active{% endif %}"> {% for title, mapping in bag("navigation").items() %}
<a class="nav__navlink {% if this._path == '/' %}-active{% endif %}" href="{{ '/'|url }}">home</a> <li class="nav__navitem
</li> {%- if this._path == mapping.href or mapping.href != '/' and this.is_child_of(mapping.href) %}
{% for href, title in [ -active
['/about', 'about'], {%- endif -%}
['/specs', 'specs'], ">
['/legal', 'legal'] <a class="nav__navlink {% if this._path == mapping.href %}-active{% endif %}" href="{{ mapping.href|url }}">
] {{ title }}
%} </a>
<li class="nav__navitem {% if this.is_child_of(href) %}-active{% endif %}"> {% if mapping.list_childs %}
<a class="nav__navlink {% if this.is_child_of(href) %}-active{% endif %}" href="{{ href|url }}">{{ title }}</a></li> <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 %} {% endfor %}
</ul> </ul>
</nav> </nav>