Skip to content

Latest commit

 

History

History
90 lines (85 loc) · 3.82 KB

File metadata and controls

90 lines (85 loc) · 3.82 KB
sectionclass h2
sectionid navigation
parent-id content
number 3200
title Navigation

The navigation is dynamic, so you don't have to manually add every page.

In this section I'll just quickly plop in the code, in case you would like to have the fourth level displayed as well.

default 3-level:

{% highlight html %} {% raw %}

    {% assign level-1 = site.entries | where: "sectionclass", "h1" | sort: "number"%} {% for entry in level-1 %}
  • {{ entry.title }} {% if entry.is-parent %}
      {% assign level-2 = site.entries | where: "parent-id", entry.sectionid | sort: "number" %} {% for child in level-2 %}
    • {{ child.title }} {% if child.is-parent %}
        {% assign level-3 = site.entries | where: "parent-id", child.sectionid | sort: "number" %} {% for grandchild in level-3 %}
      • {{ grandchild.title }}
      • {% endfor %}
      {% endif %}
    • {% endfor %}
    {% endif %}
  • {% endfor %}
{% endraw %} {% endhighlight %}

4-level nav:

{% highlight html %} {% raw %}

    {% assign level-1 = site.entries | where: "sectionclass", "h1" | sort: "number"%} {% for entry in level-1 %}
  • {{ entry.title }} {% if entry.is-parent %}
      {% assign level-2 = site.entries | where: "parent-id", entry.sectionid | sort: "number" %} {% for child in level-2 %}
    • {{ child.title }} {% if child.is-parent %}
        {% assign level-3 = site.entries | where: "parent-id", child.sectionid | sort: "number" %} {% for grandchild in level-3 %}
      • {{ grandchild.title }} {% if grandchild.is-parent %}
          {% assign level-4 = site.entries | where: "parent-id", grandchild.sectionid | sort: "number" %} {% for great-grandchild in level-4 %}
        • {{ great-grandchild.title }}
        • {% endfor %}
        {% endif %}
      • {% endfor %}
      {% endif %}
    • {% endfor %}
    {% endif %}
  • {% endfor %}
{% endraw %} {% endhighlight %}