Sidenav now shows current page

This commit is contained in:
Paul Pacheco 2018-12-20 10:06:24 -06:00
parent 00b6cb631d
commit d473ed8dc5
2 changed files with 40 additions and 30 deletions

View File

@ -0,0 +1,36 @@
{% if include.item.children %}
<a href="#submenu_{{include.id}}" aria-controls="submenu_{{include.id}}" data-toggle="collapse" aria-expanded="false" class="bd-toc-link dropdown-toggle">{{include.item.title}}</a>
{% assign pageurl = page.url | remove: '.html' %}
{% capture capturechild %}
{% for child in include.item.children %}
{% assign active = "" %}
{% if pageurl == child.url %}
{% assign active = "active bd-sidenav-active" %}
{% endif %}
<li class="hello {{active}}">
{% assign childid = include.id | append: '_' | append: forloop.index %}
{% include f_sidebar_nav.html item=child id=childid %}
</li>
{% endfor %}
{% endcapture %}
{% assign show = "" %}
{% if capturechild contains 'bd-sidenav-active' %}
{% assign show = "show" %}
{% endif %}
<ul class="collapse nav bd-sidenav {{show}}" id="submenu_{{include.id}}">
{{ capturechild }}
</ul>
{% else %}
<a href="{{include.item.url | relative_url}}">{{include.item.title}}</a>
{% endif %}

View File

@ -1,37 +1,11 @@
<div class="col-12 col-md-3 col-xl-2 bd-sidebar">
<nav class="collapse bd-links" id = "sidebar">
{% for category in site.data.navigation %}
{% assign catid = forloop.index %}
{% for child in site.data.navigation %}
<div class="bd-toc-item">
<a href="#submenu_{{catid}}" aria-controls="submenu_{{catid}}" data-toggle="collapse" aria-expanded="false" class="bd-toc-link dropdown-toggle">{{category.title}}</a>
<ul class="collapse nav bd-sidenav" id="submenu_{{catid}}">
{% for document in category.children %}
{% assign docid = forloop.index %}
<li>
{% if document.children %}
<a href="#submenu_{{catid}}_{{docid}}" aria-controls="submenu_{{catid}}_{{docid}}" data-toggle="collapse" aria-expanded="false" class="bd-toc-link dropdown-toggle">{{document.title}}</a>
<ul class="collapse nav bd-sidenav" id="submenu_{{catid}}_{{docid}}">
{% for child in document.children %}
<li>
<a href="{{child.url | relative_url}}">{{child.title}}</a>
</li>
{% endfor %}
</ul>
{% else %}
<a href="{{document.url | relative_url}}">{{document.title}}</a>
{% endif %}
</li>
{% endfor %}
</ul>
{% assign childid = ("submenu_" | append: forloop.index) %}
{% include f_sidebar_nav.html item=child id=childid %}
</div>
{% endfor %}
</nav>
</div>