DRY up archives by using an include

This commit is contained in:
Michael Rose 2016-03-05 21:29:39 -05:00
parent 8e838e1062
commit 0a4c90e031
7 changed files with 14 additions and 44 deletions

View file

@ -0,0 +1,8 @@
<article itemscope itemtype="http://schema.org/CreativeWork">
{% if post.link %}
<h2 class="link-post" itemprop="headline"><a href="{{ absurl }}{{ post.url }}">{{ post.title | markdownify | remove: "<p>" | remove: "</p>" }}</a> <a href="{{ post.link }}" target="_blank"><i class="fa fa-link"></i></a></h2>
{% else %}
<h2 itemprop="headline"><a href="{{ absurl }}{{ post.url }}">{{ post.title | markdownify | remove: "<p>" | remove: "</p>" }}</a></h2>
{% if post.excerpt %}<p itemprop="description">{{ post.excerpt | strip_html | truncate: 160 }}</p>{% endif %}
{% endif %}
</article>

View file

@ -7,13 +7,6 @@ layout: default
<div class="archive">
<h3><a href="{{ absurl }}/posts/">Recent Posts</a></h3>
{% for post in site.posts limit:5 %}
<article itemscope itemtype="http://schema.org/CreativeWork">
{% if post.link %}
<h2 class="link-post" itemprop="headline"><a href="{{ absurl }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a> <a href="{{ post.link }}" target="_blank" title="{{ post.title }}"><i class="fa fa-link"></i></a></h2>
{% else %}
<h2 itemprop="headline"><a href="{{ absurl }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a></h2>
<p itemprop="description">{{ post.excerpt | strip_html | truncate: 160 }}</p>
{% endif %}
</article>
{% include post-single.html %}
{% endfor %}
</div><!-- /#index -->

View file

@ -10,13 +10,6 @@ title: "Posts by Category"
{% assign posts = group_items[forloop.index0] %}
<h3>{{ category }}</h3>
{% for post in posts %}
<article itemscope itemtype="http://schema.org/CreativeWork">
{% if post.link %}
<h2 class="link-post" itemprop="headline"><a href="{{ absurl }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a> <a href="{{ post.link }}" target="_blank" title="{{ post.title }}"><i class="fa fa-link"></i></a></h2>
{% else %}
<h2 itemprop="headline"><a href="{{ absurl }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a></h2>
<p itemprop="description">{{ post.excerpt | markdownify | strip_html | strip_newlines | escape_once }}</p>
{% endif %}
</article>
{% include post-single.html %}
{% endfor %}
{% endfor %}

View file

@ -16,10 +16,7 @@ permalink: /collection-archive/
{% endunless %}
{% for post in collection.docs %}
{% unless collection.output == false or collection.label == 'posts' %}
<article itemscope itemtype="http://schema.org/CreativeWork">
<h2 itemprop="headline"><a href="{{ absurl }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a></h2>
{% if post.excerpt %}<p itemprop="description">{{ post.excerpt | markdownify | strip_html | strip_newlines | escape_once }}</p>{% endif %}
</article>
{% include post-single.html %}
{% endunless %}
{% endfor %}
{% endfor %}

View file

@ -10,13 +10,6 @@ permalink: /recipes/
{% assign posts = group_items[forloop.index0] %}
<h3>{{ category }}</h3>
{% for post in posts %}
<article itemscope itemtype="http://schema.org/CreativeWork">
{% if post.link %}
<h2 class="link-post" itemprop="headline"><a href="{{ absurl }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a> <a href="{{ post.link }}" target="_blank" title="{{ post.title }}"><i class="fa fa-link"></i></a></h2>
{% else %}
<h2 itemprop="headline"><a href="{{ absurl }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a></h2>
<p itemprop="description">{{ post.excerpt | markdownify | strip_html | strip_newlines | escape_once }}</p>
{% endif %}
</article>
{% include post-single.html %}
{% endfor %}
{% endfor %}

View file

@ -10,13 +10,6 @@ title: "Posts by Tags"
{% assign posts = group_items[forloop.index0] %}
<h3>{{ tag }}</h3>
{% for post in posts %}
<article itemscope itemtype="http://schema.org/CreativeWork">
{% if post.link %}
<h2 class="link-post" itemprop="headline"><a href="{{ absurl }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a> <a href="{{ post.link }}" target="_blank" title="{{ post.title }}"><i class="fa fa-link"></i></a></h2>
{% else %}
<h2 itemprop="headline"><a href="{{ absurl }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a></h2>
<p itemprop="description">{{ post.excerpt | markdownify | strip_html | strip_newlines | escape_once }}</p>
{% endif %}
</article>
{% include post-single.html %}
{% endfor %}
{% endfor %}

View file

@ -11,12 +11,5 @@ title: "Posts by Year"
<h3>{{ year }}</h3>
{% capture written_year %}{{ year }}{% endcapture %}
{% endif %}
<article itemscope itemtype="http://schema.org/CreativeWork">
{% if post.link %}
<h2 class="link-post" itemprop="headline"><a href="{{ absurl }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a> <a href="{{ post.link }}" target="_blank" title="{{ post.title }}"><i class="fa fa-link"></i></a></h2>
{% else %}
<h2 itemprop="headline"><a href="{{ absurl }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a></h2>
<p itemprop="description">{{ post.excerpt | markdownify | strip_html | strip_newlines | escape_once }}</p>
{% endif %}
</article>
{% include post-single.html %}
{% endfor %}