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) ## [4.9.0](https://github.com/mmistakes/minimal-mistakes/releases/tag/4.9.0)
### Enhancements ### Enhancements

View file

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

View file

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

View file

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