Skip to content

Instantly share code, notes, and snippets.

@jlisee
Forked from rey/archive.html
Last active December 23, 2015 02:08
Show Gist options
  • Save jlisee/6564460 to your computer and use it in GitHub Desktop.
Save jlisee/6564460 to your computer and use it in GitHub Desktop.
Updated Jekyll archive template. Reduced code duplication and heading bug fix.
<section id="archive">
{% capture this_year %}{{ site.time | date: '%Y' }}{% endcapture %}
{% capture post_year %}{{ site.posts[0].date | date: '%Y' }}{% endcapture %}
{% if this_year == post_year %}
<h3>This year's posts</h3>
{% else %}
<h3>{{ post_year }}</h3>
{% endif %}
{%for post in site.posts %}
{% unless post.next %}
<ul class="this">
{% else %}
{% capture year %}{{ post.date | date: '%Y' }}{% endcapture %}
{% capture nyear %}{{ post.next.date | date: '%Y' }}{% endcapture %}
{% if year != nyear %}
</ul>
<h3>{{ post.date | date: '%Y' }}</h3>
<ul class="past">
{% endif %}
{% endunless %}
<li><time>{{ post.date | date:"%d %b" }}</time><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</section>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment