Skip to content

Commit

Permalink
try navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
iesemtger committed Dec 18, 2023
1 parent 2a90d91 commit bfae22e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/_data/navigation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- title: Home
url: /

- title: Angebotsentwicklung
url: /Angebotsentwicklung/

37 changes: 37 additions & 0 deletions docs/_includes/navigation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

{% for entry in site.data.navigation %}
{% capture fullurl %}{{ site.baseurl }}{{ entry.url }}{% endcapture %}
{% if fullurl == page.url %}
{% assign current_page = fullurl %}
{% break %}
{% elsif page.url contains fullurl %}
{% assign current_page = fullurl %}
{% endif %}
{% endfor %}

<!-- Then we build the nav bar. -->
<nav>
<ul>
{% for entry in site.data.navigation %}
{% if entry.url == current_page %}
{% assign current = ' class="current"' %}
{% else %}
<!-- We have to declare it 'null' to ensure it doesn't propagate. -->
{% assign current = null %}
{% endif %}
{% assign sublinks = entry.sublinks %}
{% if sublinks %}
<li{{ current }}>
<a href="{{ site.baseurl }}{{ entry.url }}">{{ entry.title }}</a>
<ul>
{% for sublink in sublinks %}
<li><a href="{{ site.baseurl }}{{ sublink.url }}">{{ sublink.title }}</a></li>
{% endfor %}
</ul>
</li>
{% else %}
<li{{ current }}><a href="{{ site.baseurl }}{{ entry.url }}">{{ entry.title }}</a></li>
{% endif %}
{% endfor %}
</ul>
</nav>

0 comments on commit bfae22e

Please sign in to comment.