Lego2012
9/26/2016 - 9:18 PM

Highlight Tab: Version 5

Highlight Tab: Version 5

<!--
Now pages can be "grouped". To give a page a group you need to specify it in the pages YAML Front Matter:
-->

---
title: blah
categories: blah
group: "navigation"
---

<!--
Finally you can use your new code! Wherever you need your navigation to go in your template, simply "call" your include file and pass it some pages and the group you want to display:
-->

<ul>
  {% assign pages_list = site.pages %}
  {% assign group = 'navigation' %}
  {% include pages_list %}
</ul>

<!--
Put the following code in a file in the _includes folder at: ./_includes/pages_list
-->

{% for node in pages_list %}
  {% if group == null or group == node.group %}
    {% if page.url == node.url %}
      <li class="active"><a href="{{node.url}}" class="active">{{node.title}}</a></li>
    {% else %}
      <li><a href="{{node.url}}">{{node.title}}</a></li>
    {% endif %}
  {% endif %}
{% endfor %}
{% assign pages_list = nil %}
{% assign group = nil %}