Skip to content

Instantly share code, notes, and snippets.

@brandonkelly
Created March 5, 2014 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonkelly/9362241 to your computer and use it in GitHub Desktop.
Save brandonkelly/9362241 to your computer and use it in GitHub Desktop.
{% macro entryLink(entry, selEntry) %}
{% if entry.type == 'link' %}
<a href="{{ url(entry.linkUrl) }}">{{ entry.title }}<span class="external"></span></a>
{% elseif entry.type == 'headingOnly' %}
{% set nextEntry = entry.getNext() %}
{% if nextEntry %}
<a href="{{ nextEntry.url }}">{{ entry.title }}</a>
{% else %}
{{ entry.title }}
{% endif %}
{% else %}
<a href="{{ entry.url }}"{% if selEntry and entry.id == selEntry.id %} class="sel active"{% endif %}>{{ entry.title }}</a>
{% endif %}
{% endmacro %}
{% from _self import entryLink %}
{% set entryParent = selEntry.getParent() %}
{% nav otherEntry in allEntries %}
{% set parent = nav.parent ? nav.parent.otherEntry : null %}
{% set show = otherEntry.depth < 3 or parent.type == 'headingOnly' or parent.id == entry.id or parent.id == entryParent.id %}
{% if show %}
{% if otherEntry.depth == 1 %}
<h5>{{ otherEntry.title }}</h5>
{% else %}
<li>
{{ entryLink(otherEntry, entry) }}
{% endif %}
{% endif %}
{% ifchildren %}
<ul>
{% children %}
</ul>
{% endifchildren %}
{% if otherEntry.depth > 1 and show %}
</li>
{% endif %}
{% endnav %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment