-
-
Save jlisee/6564460 to your computer and use it in GitHub Desktop.
Updated Jekyll archive template. Reduced code duplication and heading bug fix.
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
<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