From 9634bb84fb488cd1f92a1734cfb4c51305f20aa6 Mon Sep 17 00:00:00 2001 From: Michael Rose Date: Fri, 5 Jan 2018 20:47:34 -0500 Subject: [PATCH] Simplify year archive Liquid --- CHANGELOG.md | 8 ++++++++ docs/_docs/18-history.md | 10 +++++++++- docs/_pages/year-archive.html | 14 ++++++-------- test/_pages/year-archive.html | 15 ++++++--------- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c69cacbf..023fb55e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/docs/_docs/18-history.md b/docs/_docs/18-history.md index 276430eb..bb8ebfb8 100644 --- a/docs/_docs/18-history.md +++ b/docs/_docs/18-history.md @@ -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 diff --git a/docs/_pages/year-archive.html b/docs/_pages/year-archive.html index d2fa0685..13135a91 100644 --- a/docs/_pages/year-archive.html +++ b/docs/_pages/year-archive.html @@ -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 %} -

{{ year }}

- {% capture written_year %}{{ year }}{% endcapture %} - {% endif %} - {% include archive-single.html %} +{% assign postsByYear = site.posts | group_by_exp:"post", "post.date | date: '%Y'" %} +{% for year in postsByYear %} +

{{ year.name }}

+ {% for post in year.items %} + {% include archive-single.html %} + {% endfor %} {% endfor %} \ No newline at end of file diff --git a/test/_pages/year-archive.html b/test/_pages/year-archive.html index 7198ab65..13135a91 100644 --- a/test/_pages/year-archive.html +++ b/test/_pages/year-archive.html @@ -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 %} -

{{ year }}

- {% capture written_year %}{{ year }}{% endcapture %} - {% endif %} - {% include archive-single.html %} +{% assign postsByYear = site.posts | group_by_exp:"post", "post.date | date: '%Y'" %} +{% for year in postsByYear %} +

{{ year.name }}

+ {% for post in year.items %} + {% include archive-single.html %} + {% endfor %} {% endfor %} \ No newline at end of file