Created
February 6, 2023 23:58
-
-
Save brennanbrown/b471a01e966c3f7e0b2669e6e4057b0c to your computer and use it in GitHub Desktop.
Displaying posts in Jekyll, organized by month. (Originally used on journalbar)
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
--- | |
layout: default | |
--- | |
<div class="home"> | |
{% include header.html %} | |
{% include intro.html %} | |
<hr> | |
<section> | |
<h1 id="posts"> | |
Weekly Posts | |
</h1> | |
<!-- https://gist.github.com/tuananh/7432553 --> | |
{% assign postsByYearMonth = site.posts | group_by_exp:"post", "post.date | date: '%B %Y'" %} | |
{% for yearMonth in postsByYearMonth %} | |
<h2>{{ yearMonth.name }}</h2> | |
<ul class="post-list"> | |
{% for post in yearMonth.items %} | |
<li> | |
<time datetime="{{ post.date | date_to_xmlschema }}">{{ post.date | date: "%a, %b. %d" }}</time> | |
<a href="{{ post.url | prepend: site.baseurl | prepend: site.url }}">{{ post.title }}</a><br> | |
<small> | |
<em>{{ post.content | strip_html | escape | truncate: 300}}</em> | |
</small> | |
</li><br> | |
{% endfor %} | |
</ul> | |
{% endfor %} | |
</section> | |
</div> | |
<hr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment