DRY up archive include

- Combine grid and list view into one include
This commit is contained in:
Michael Rose
2016-03-19 20:58:17 -04:00
parent da90ccaf49
commit 109f4ffb44
16 changed files with 75 additions and 76 deletions

View File

@ -6,12 +6,12 @@ author_profile: false
---
{% include base_path %}
{% include group-by-array collection=site.posts field='categories' %}
{% include group-by-array collection=site.posts field="categories" %}
{% for category in group_names %}
{% assign posts = group_items[forloop.index0] %}
<h2 id="{{ category | slugify }}" class="archive__subtitle">{{ category }}</h2>
{% for post in posts %}
{% include archive-list-single.html %}
{% include archive-single.html %}
{% endfor %}
{% endfor %}

View File

@ -9,7 +9,7 @@ author_profile: false
{% capture written_label %}'None'{% endcapture %}
{% for collection in site.collections %}
{% unless collection.output == false or collection.label == 'posts' %}
{% unless collection.output == false or collection.label == "posts" %}
{% capture label %}{{ collection.label }}{% endcapture %}
{% if label != written_label %}
<h2 id="{{ label | slugify }}" class="archive__subtitle">{{ label }}</h2>
@ -17,8 +17,8 @@ author_profile: false
{% endif %}
{% endunless %}
{% for post in collection.docs %}
{% unless collection.output == false or collection.label == 'posts' %}
{% include archive-list-single.html %}
{% unless collection.output == false or collection.label == "posts" %}
{% include archive-single.html %}
{% endunless %}
{% endfor %}
{% endfor %}

View File

@ -7,5 +7,5 @@ author_profile: false
{% include base_path %}
{% for post in site.pages %}
{% include archive-list-single.html %}
{% include archive-single.html %}
{% endfor %}

View File

@ -5,12 +5,12 @@ permalink: /portfolio/
---
{% include base_path %}
{% include group-by-array collection=site.portfolio field='categories' %}
{% include group-by-array collection=site.portfolio field="categories" %}
{% for category in group_names %}
{% assign posts = group_items[forloop.index0] %}
<h2 id="{{ category | slugify }}" class="archive__subtitle">{{ category }}</h2>
{% for post in posts %}
{% include archive-list-single.html %}
{% include archive-single.html %}
{% endfor %}
{% endfor %}

View File

@ -8,5 +8,5 @@ author_profile: false
{% include base_path %}
{% for post in site.recipes %}
{% include archive-list-single.html %}
{% include archive-single.html %}
{% endfor %}

View File

@ -11,18 +11,18 @@ A list of all the posts and pages found on the site. For you robots out there is
<h2>Pages</h2>
{% for post in site.pages %}
{% include archive-list-single.html %}
{% include archive-single.html %}
{% endfor %}
<h2>Posts</h2>
{% for post in site.posts %}
{% include archive-list-single.html %}
{% include archive-single.html %}
{% endfor %}
{% capture written_label %}'None'{% endcapture %}
{% for collection in site.collections %}
{% unless collection.output == false or collection.label == 'posts' %}
{% unless collection.output == false or collection.label == "posts" %}
{% capture label %}{{ collection.label }}{% endcapture %}
{% if label != written_label %}
<h2>{{ label }}</h2>
@ -30,8 +30,8 @@ A list of all the posts and pages found on the site. For you robots out there is
{% endif %}
{% endunless %}
{% for post in collection.docs %}
{% unless collection.output == false or collection.label == 'posts' %}
{% include archive-list-single.html %}
{% unless collection.output == false or collection.label == "posts" %}
{% include archive-single.html %}
{% endunless %}
{% endfor %}
{% endfor %}

View File

@ -6,12 +6,12 @@ author_profile: false
---
{% include base_path %}
{% include group-by-array collection=site.posts field='tags' %}
{% include group-by-array collection=site.posts field="tags" %}
{% for tag in group_names %}
{% assign posts = group_items[forloop.index0] %}
<h2 id="{{ tag | slugify }}" class="archive__subtitle">{{ tag }}</h2>
{% for post in posts %}
{% include archive-list-single.html %}
{% include archive-single.html %}
{% endfor %}
{% endfor %}

View File

@ -13,5 +13,5 @@ author_profile: false
<h2 id="{{ year | slugify }}" class="archive__subtitle">{{ year }}</h2>
{% capture written_year %}{{ year }}{% endcapture %}
{% endif %}
{% include archive-list-single.html %}
{% include archive-single.html %}
{% endfor %}