Created
January 22, 2016 09:44
-
-
Save callumflack/4f997ec1763552433c04 to your computer and use it in GitHub Desktop.
Adding class to main menu based on whether or not a post has a certain tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% assign focus = site.pages.news.taxonomy.tags.focus-magazine %} | |
<li> | |
<a href="{{focus.url}}" | |
{% if url == focus.url %}class="is-selected" | |
{% elsif taxonomy.tags.all contains "focus-magazine" %}class="is-selected" | |
{% endif %}> | |
{{focus}} | |
</a> | |
</li> | |
{% assign flag = "false" %} | |
{% for tagset in site.pages.news.taxonomy %} | |
{% for tag in tagset %} | |
{% if tag.value == "focus-magazine" %} | |
{% assign flag = "true" %} | |
{% endif %} | |
{% endfor %} | |
{% endfor %} | |
<li> | |
<a href="{{focus.url}}" | |
{% if url == focus.url %}class="is-selected" | |
{% elsif type == "post" and parent.slug == news.slug and flag != "true" %}class="is-selected" | |
{% endif %}> | |
{{focus}} | |
</a> | |
</li> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment