Simplify year archive Liquid

This commit is contained in:
Michael Rose 2018-01-05 20:47:34 -05:00
parent 6e0ef33ec7
commit 9634bb84fb
4 changed files with 29 additions and 18 deletions

View file

@ -1,3 +1,11 @@
## Unreleased
### Enhancements
* Simplify year archive Liquid.
### Bug Fixes
## [4.9.0](https://github.com/mmistakes/minimal-mistakes/releases/tag/4.9.0)
### Enhancements

View file

@ -4,10 +4,18 @@ permalink: /docs/history/
excerpt: "Change log of enhancements and bug fixes made to the theme."
sidebar:
nav: docs
last_modified_at: 2018-01-04T22:50:34-05:00
last_modified_at: 2018-01-05T20:47:28-05:00
toc: true
---
## Unreleased
### Enhancements
* Simplify year archive Liquid.
### Bug Fixes
## [4.9.0](https://github.com/mmistakes/minimal-mistakes/releases/tag/4.9.0)
### Enhancements

View file

@ -5,12 +5,10 @@ title: "Posts by Year"
author_profile: true
---
{% capture written_year %}'None'{% endcapture %}
{% for post in site.posts %}
{% capture year %}{{ post.date | date: '%Y' }}{% endcapture %}
{% if year != written_year %}
<h2 id="{{ year | slugify }}" class="archive__subtitle">{{ year }}</h2>
{% capture written_year %}{{ year }}{% endcapture %}
{% endif %}
{% assign postsByYear = site.posts | group_by_exp:"post", "post.date | date: '%Y'" %}
{% for year in postsByYear %}
<h2 id="{{ year.name | slugify }}" class="archive__subtitle">{{ year.name }}</h2>
{% for post in year.items %}
{% include archive-single.html %}
{% endfor %}
{% endfor %}

View file

@ -5,13 +5,10 @@ title: "Posts by Year"
author_profile: true
---
{% include base_path %}
{% capture written_year %}'None'{% endcapture %}
{% for post in site.posts %}
{% capture year %}{{ post.date | date: '%Y' }}{% endcapture %}
{% if year != written_year %}
<h2 id="{{ year | slugify }}" class="archive__subtitle">{{ year }}</h2>
{% capture written_year %}{{ year }}{% endcapture %}
{% endif %}
{% assign postsByYear = site.posts | group_by_exp:"post", "post.date | date: '%Y'" %}
{% for year in postsByYear %}
<h2 id="{{ year.name | slugify }}" class="archive__subtitle">{{ year.name }}</h2>
{% for post in year.items %}
{% include archive-single.html %}
{% endfor %}
{% endfor %}