From 0a4c90e0317e63e8e99f7c578ff1251e874f1f2c Mon Sep 17 00:00:00 2001 From: Michael Rose Date: Sat, 5 Mar 2016 21:29:39 -0500 Subject: [PATCH] DRY up archives by using an include --- _includes/post-single.html | 8 ++++++++ _layouts/home.html | 9 +-------- _pages/category-archive.html | 9 +-------- _pages/collection-archive.html | 5 +---- _pages/recipes-archive.html | 9 +-------- _pages/tag-archive.html | 9 +-------- _pages/year-archive.html | 9 +-------- 7 files changed, 14 insertions(+), 44 deletions(-) create mode 100644 _includes/post-single.html diff --git a/_includes/post-single.html b/_includes/post-single.html new file mode 100644 index 00000000..e391187f --- /dev/null +++ b/_includes/post-single.html @@ -0,0 +1,8 @@ +
+ {% if post.link %} +

{{ post.title | markdownify | remove: "

" | remove: "

" }}

+ {% else %} +

{{ post.title | markdownify | remove: "

" | remove: "

" }}

+ {% if post.excerpt %}

{{ post.excerpt | strip_html | truncate: 160 }}

{% endif %} + {% endif %} +
\ No newline at end of file diff --git a/_layouts/home.html b/_layouts/home.html index 4d4dee22..e45ba57e 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -7,13 +7,6 @@ layout: default

Recent Posts

{% for post in site.posts limit:5 %} - + {% include post-single.html %} {% endfor %}
\ No newline at end of file diff --git a/_pages/category-archive.html b/_pages/category-archive.html index 6e6f5126..9babd6d9 100644 --- a/_pages/category-archive.html +++ b/_pages/category-archive.html @@ -10,13 +10,6 @@ title: "Posts by Category" {% assign posts = group_items[forloop.index0] %}

{{ category }}

{% for post in posts %} -
- {% if post.link %} -

{{ post.title }}

- {% else %} -

{{ post.title }}

-

{{ post.excerpt | markdownify | strip_html | strip_newlines | escape_once }}

- {% endif %} -
+ {% include post-single.html %} {% endfor %} {% endfor %} \ No newline at end of file diff --git a/_pages/collection-archive.html b/_pages/collection-archive.html index e85819d9..e52157fd 100644 --- a/_pages/collection-archive.html +++ b/_pages/collection-archive.html @@ -16,10 +16,7 @@ permalink: /collection-archive/ {% endunless %} {% for post in collection.docs %} {% unless collection.output == false or collection.label == 'posts' %} -
-

{{ post.title }}

- {% if post.excerpt %}

{{ post.excerpt | markdownify | strip_html | strip_newlines | escape_once }}

{% endif %} -
+ {% include post-single.html %} {% endunless %} {% endfor %} {% endfor %} \ No newline at end of file diff --git a/_pages/recipes-archive.html b/_pages/recipes-archive.html index 5c396b8f..27643711 100644 --- a/_pages/recipes-archive.html +++ b/_pages/recipes-archive.html @@ -10,13 +10,6 @@ permalink: /recipes/ {% assign posts = group_items[forloop.index0] %}

{{ category }}

{% for post in posts %} -
- {% if post.link %} -

{{ post.title }}

- {% else %} -

{{ post.title }}

-

{{ post.excerpt | markdownify | strip_html | strip_newlines | escape_once }}

- {% endif %} -
+ {% include post-single.html %} {% endfor %} {% endfor %} \ No newline at end of file diff --git a/_pages/tag-archive.html b/_pages/tag-archive.html index 503904ef..c10941e5 100644 --- a/_pages/tag-archive.html +++ b/_pages/tag-archive.html @@ -10,13 +10,6 @@ title: "Posts by Tags" {% assign posts = group_items[forloop.index0] %}

{{ tag }}

{% for post in posts %} -
- {% if post.link %} -

{{ post.title }}

- {% else %} -

{{ post.title }}

-

{{ post.excerpt | markdownify | strip_html | strip_newlines | escape_once }}

- {% endif %} -
+ {% include post-single.html %} {% endfor %} {% endfor %} \ No newline at end of file diff --git a/_pages/year-archive.html b/_pages/year-archive.html index ebf708cd..984b6ff9 100644 --- a/_pages/year-archive.html +++ b/_pages/year-archive.html @@ -11,12 +11,5 @@ title: "Posts by Year"

{{ year }}

{% capture written_year %}{{ year }}{% endcapture %} {% endif %} -
- {% if post.link %} -

{{ post.title }}

- {% else %} -

{{ post.title }}

-

{{ post.excerpt | markdownify | strip_html | strip_newlines | escape_once }}

- {% endif %} -
+ {% include post-single.html %} {% endfor %} \ No newline at end of file