Skip to content

Instantly share code, notes, and snippets.

@bighairydave
Last active August 29, 2015 14:14
Show Gist options
  • Save bighairydave/8f038e0f9cbad12ba3cb to your computer and use it in GitHub Desktop.
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.
# 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