Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. {% capture html %}
  2.  
  3. {% assign childCount = '' %}
  4. {% comment %} Make sure there will be pages before making the ul tag. {% endcomment %}
  5. {% assign entries = site.pages | sort: "path" %}
  6. {% for entry in entries %}
  7. {% capture slug %}{{ entry.url | split: "/" | last }}{% endcapture %}
  8. {% capture current %}{{ entry.url | remove: slug | remove: "//" | append: "/" }}{% endcapture %}
  9.  
  10. {% if current == include.context %}
  11. {% capture childCount %}{{ childCount }}*{% endcapture %}
  12. {% endif %}
  13.  
  14. {% endfor %}
  15.  
  16. {% if childCount.size > 0 %}
  17. <ul>
  18. {% if include.context == "/" %}
  19. <li class="{% if page.url == "/" %}active{% endif %}">
  20. <a href="{{ site.baseurl }}/">{{ site.title }}</a>
  21. </li>
  22. {% endif %}
  23.  
  24. {% assign entries = site.pages | sort: "path" %}
  25. {% for entry in entries %}
  26. {% capture slug %}{{ entry.url | split: "/" | last }}{% endcapture %}
  27. {% capture current %}{{ entry.url | remove: slug | remove: "//" | append: "/" }}{% endcapture %}
  28.  
  29. {% if current == include.context %}
  30. <li class="{% if page.url contains entry.url %}active{% endif %}">
  31. {% capture subMenu %}{% include navigation.html context=entry.url %}{% endcapture %}
  32. {% if subMenu.size > 0 %}
  33. <a href="{{ site.baseurl }}{{ entry.url }}">{{ entry.title }}</a>
  34. {% endif %}
  35. {% unless subMenu.size > 0 %}
  36. {% comment %}
  37. This if/unless is optional. Useful if you want clicking on the non-text part
  38. of the <li> row to expand, but you want have the leaf nodes of the navigation
  39. tree browse when anywhere in the <li> is clicked, not just the text of the <a>.
  40. If not, just remove the unless entirely and remove the if/endif around the <a>
  41. above.
  42. {% endcomment %}
  43. <a class="make-the-internal-a-tag-inline-block-and-100%w/h" href="{{ site.baseurl }}{{ entry.url }}">{{ entry.title }}</a>
  44. {% endunless %}
  45. {{ subMenu }}
  46. </li>
  47. {% endif %}
  48.  
  49. {% endfor %}
  50. </ul>
  51. {% endif %}
  52. {% endcapture %}{{ html | strip_newlines | replace:' ','' | replace:' ','' | replace:' ',' ' }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement