37 lines
1.3 KiB
HTML
37 lines
1.3 KiB
HTML
{% 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 %}
|
|
<!-- uses yellow, you can change to any other hexadecimal colour code. -->
|
|
{% assign current = ' style="background-color: #FFFFFF"' %}
|
|
{% 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> |