Split post list item into an include to keeps things DRY

This commit is contained in:
Kyle Gordy 2019-12-02 12:34:59 -05:00
parent 76f95ba690
commit 566a4418f1
3 changed files with 29 additions and 47 deletions

View File

@ -58,31 +58,12 @@
<section class="feat-post__secondary">
<h3 class="section-heading mb-0 text-plum">Featured Series</h3>
<ul class="post-list text-length-sm">
{% assign featured-series = site.tags.featured-series | sort: 'date' %}
<!-- Pick a series to features using its unique tag - i.e. di-series -->
{% assign featured-series = site.tags.di-series | sort: 'date' %}
{% for post in featured-series limit: 2 %}
<li class="post-list__item">
<!-- Post title -->
<h4 class="post-list__heading">
<a href="{{ post.url | relative_url }}" class="link-text-color">
{{ post.title | escape }}
</a>
</h4>
<!-- Post metadata -->
<span class="post-list__author">
<span class="visually-hidden">Author:</span>
{%- if site.data.authors[post.author] -%}
{{ site.data.authors[post.author].name}}
{%- else -%}
{{ post.author }}
{%- endif -%}
</span><!--
--><time class="post-list__date" datetime="{{ post.date | date_to_xmlschema }}">
{%- assign date_format = site.date_format -%}
{{ post.date | date: date_format }}</time>
</li>
<!-- Post item template -->
{% include post-list-item.html %}
{% endfor %}
</ul>

View File

@ -0,0 +1,23 @@
<li class="post-list__item">
<!-- Post title -->
<h4 class="post-list__heading">
<a href="{{ post.url | relative_url }}" class="link-text-color">
{{ post.title | escape }}
</a>
</h4>
<!-- Post metadata -->
<span class="post-list__author">
<span class="visually-hidden">Author:</span>
{%- if site.data.authors[post.author] -%}
{{ site.data.authors[post.author].name}}
{%- else -%}
{{ post.author }}
{%- endif -%}
</span><!--
--><time class="post-list__date" datetime="{{ post.date | date_to_xmlschema }}">
{%- assign date_format = site.date_format -%}
{{ post.date | date: date_format }}</time>
</li>

View File

@ -19,29 +19,7 @@ title: Blog
<!-- Post -->
{%- for post in paginator.posts -%}
<li class="post-list__item">
<!-- Post title -->
<h4 class="post-list__heading">
<a href="{{ post.url | relative_url }}" class="link-text-color">
{{ post.title | escape }}
</a>
</h4>
<!-- Post metadata -->
<span class="post-list__author">
<span class="visually-hidden">Author:</span>
{%- if site.data.authors[post.author] -%}
{{ site.data.authors[post.author].name}}
{%- else -%}
{{ post.author }}
{%- endif -%}
</span><!--
--><time class="post-list__date" datetime="{{ post.date | date_to_xmlschema }}">
{%- assign date_format = site.date_format -%}
{{ post.date | date: date_format }}</time>
</li>
{% include post-list-item.html %}
{%- endfor -%}
</ul>