Last active
August 29, 2015 14:14
-
-
Save bighairydave/8f038e0f9cbad12ba3cb to your computer and use it in GitHub Desktop.
Add a list of birds specified in YAML front matter to your Jekyll post.
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
# Place this in your _posts.html layout. | |
# Add birds to your post in YAML front matter. | |
# e.g. | |
# birds: | |
# - Roc | |
# - Phoenix | |
# - Thunderbird | |
# or | |
# | |
# birds: [Roc, Phoenix, Thunderbird] | |
# | |
# classes .birdlist and .birdstring are provided for styling. | |
<div class="birdlist"> | |
{% if page.birds %} | |
<hr> | |
<h3>Birds in this entry:</h3> | |
<div class="birdstring"> | |
{% assign birdies = page.birds | sort %} | |
{% for birdy in birdies %} | |
{% unless birdy == birdies.last %} | |
{{ birdy }}, | |
{% endunless %} | |
{% endfor %} | |
{% if birdies.size > 1 %} | |
and | |
{% endif %} | |
{{ birdies.last }}. | |
</div> | |
{% endif %} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment