DRY up archives by using an include
This commit is contained in:
parent
8e838e1062
commit
0a4c90e031
7 changed files with 14 additions and 44 deletions
8
_includes/post-single.html
Normal file
8
_includes/post-single.html
Normal 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>
|
|
@ -7,13 +7,6 @@ layout: default
|
||||||
<div class="archive">
|
<div class="archive">
|
||||||
<h3><a href="{{ absurl }}/posts/">Recent Posts</a></h3>
|
<h3><a href="{{ absurl }}/posts/">Recent Posts</a></h3>
|
||||||
{% for post in site.posts limit:5 %}
|
{% for post in site.posts limit:5 %}
|
||||||
<article itemscope itemtype="http://schema.org/CreativeWork">
|
{% include post-single.html %}
|
||||||
{% 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>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div><!-- /#index -->
|
</div><!-- /#index -->
|
|
@ -10,13 +10,6 @@ title: "Posts by Category"
|
||||||
{% assign posts = group_items[forloop.index0] %}
|
{% assign posts = group_items[forloop.index0] %}
|
||||||
<h3>{{ category }}</h3>
|
<h3>{{ category }}</h3>
|
||||||
{% for post in posts %}
|
{% for post in posts %}
|
||||||
<article itemscope itemtype="http://schema.org/CreativeWork">
|
{% include post-single.html %}
|
||||||
{% 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>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
|
@ -16,10 +16,7 @@ permalink: /collection-archive/
|
||||||
{% endunless %}
|
{% endunless %}
|
||||||
{% for post in collection.docs %}
|
{% for post in collection.docs %}
|
||||||
{% unless collection.output == false or collection.label == 'posts' %}
|
{% unless collection.output == false or collection.label == 'posts' %}
|
||||||
<article itemscope itemtype="http://schema.org/CreativeWork">
|
{% include post-single.html %}
|
||||||
<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>
|
|
||||||
{% endunless %}
|
{% endunless %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
|
@ -10,13 +10,6 @@ permalink: /recipes/
|
||||||
{% assign posts = group_items[forloop.index0] %}
|
{% assign posts = group_items[forloop.index0] %}
|
||||||
<h3>{{ category }}</h3>
|
<h3>{{ category }}</h3>
|
||||||
{% for post in posts %}
|
{% for post in posts %}
|
||||||
<article itemscope itemtype="http://schema.org/CreativeWork">
|
{% include post-single.html %}
|
||||||
{% 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>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
|
@ -10,13 +10,6 @@ title: "Posts by Tags"
|
||||||
{% assign posts = group_items[forloop.index0] %}
|
{% assign posts = group_items[forloop.index0] %}
|
||||||
<h3>{{ tag }}</h3>
|
<h3>{{ tag }}</h3>
|
||||||
{% for post in posts %}
|
{% for post in posts %}
|
||||||
<article itemscope itemtype="http://schema.org/CreativeWork">
|
{% include post-single.html %}
|
||||||
{% 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>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
|
@ -11,12 +11,5 @@ title: "Posts by Year"
|
||||||
<h3>{{ year }}</h3>
|
<h3>{{ year }}</h3>
|
||||||
{% capture written_year %}{{ year }}{% endcapture %}
|
{% capture written_year %}{{ year }}{% endcapture %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<article itemscope itemtype="http://schema.org/CreativeWork">
|
{% include post-single.html %}
|
||||||
{% 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>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
Loading…
Reference in a new issue