Created
November 24, 2019 04:43
-
-
Save piharpi/6164a17dc823cd33a4306ea6e6c88bf1 to your computer and use it in GitHub Desktop.
Liquid Template language to group jekyll blog posts by year.
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
{% for post in site.posts %} | |
{% capture current_year %} | |
{{post.date | date: "%Y"}} | |
{% endcapture %} | |
{% if current_year != previous_year %} | |
{% assign previous_year = current_year %} | |
<h4 class="post-header"> | |
<span role="img" aria-label="icon-book" aria-hidden="true">🎉</span> | |
{{ current_year }} | |
</h4> | |
{% endif %} | |
<article class="posts"> | |
<span class="posts-date">{{ post.date | date: "%b %d" }}</span> | |
<header class="posts-header"> | |
<h4 class="posts-title"> | |
<a href="{{ post.url }}">{{ post.title | escape }}</a> | |
</h4> | |
</header> | |
</article> | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment