Skip to content

Commit 566a441

Browse files
committed
Split post list item into an include to keeps things DRY
1 parent 76f95ba commit 566a441

File tree

3 files changed

+29
-47
lines changed

3 files changed

+29
-47
lines changed

_includes/featured-post-hero.html

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,12 @@ <h2 class="hero__title">
5858
<section class="feat-post__secondary">
5959
<h3 class="section-heading mb-0 text-plum">Featured Series</h3>
6060
<ul class="post-list text-length-sm">
61-
{% assign featured-series = site.tags.featured-series | sort: 'date' %}
62-
{% for post in featured-series limit: 2 %}
63-
<li class="post-list__item">
64-
65-
<!-- Post title -->
66-
<h4 class="post-list__heading">
67-
<a href="{{ post.url | relative_url }}" class="link-text-color">
68-
{{ post.title | escape }}
69-
</a>
70-
</h4>
71-
72-
<!-- Post metadata -->
73-
<span class="post-list__author">
74-
<span class="visually-hidden">Author:</span>
75-
{%- if site.data.authors[post.author] -%}
76-
{{ site.data.authors[post.author].name}}
77-
{%- else -%}
78-
{{ post.author }}
79-
{%- endif -%}
80-
</span><!--
81-
--><time class="post-list__date" datetime="{{ post.date | date_to_xmlschema }}">
82-
{%- assign date_format = site.date_format -%}
83-
{{ post.date | date: date_format }}</time>
8461

85-
</li>
62+
<!-- Pick a series to features using its unique tag - i.e. di-series -->
63+
{% assign featured-series = site.tags.di-series | sort: 'date' %}
64+
{% for post in featured-series limit: 2 %}
65+
<!-- Post item template -->
66+
{% include post-list-item.html %}
8667
{% endfor %}
8768
</ul>
8869

_includes/post-list-item.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<li class="post-list__item">
2+
3+
<!-- Post title -->
4+
<h4 class="post-list__heading">
5+
<a href="{{ post.url | relative_url }}" class="link-text-color">
6+
{{ post.title | escape }}
7+
</a>
8+
</h4>
9+
10+
<!-- Post metadata -->
11+
<span class="post-list__author">
12+
<span class="visually-hidden">Author:</span>
13+
{%- if site.data.authors[post.author] -%}
14+
{{ site.data.authors[post.author].name}}
15+
{%- else -%}
16+
{{ post.author }}
17+
{%- endif -%}
18+
</span><!--
19+
--><time class="post-list__date" datetime="{{ post.date | date_to_xmlschema }}">
20+
{%- assign date_format = site.date_format -%}
21+
{{ post.date | date: date_format }}</time>
22+
23+
</li>

blog/index.html

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,7 @@
1919

2020
<!-- Post -->
2121
{%- for post in paginator.posts -%}
22-
<li class="post-list__item">
23-
24-
<!-- Post title -->
25-
<h4 class="post-list__heading">
26-
<a href="{{ post.url | relative_url }}" class="link-text-color">
27-
{{ post.title | escape }}
28-
</a>
29-
</h4>
30-
31-
<!-- Post metadata -->
32-
<span class="post-list__author">
33-
<span class="visually-hidden">Author:</span>
34-
{%- if site.data.authors[post.author] -%}
35-
{{ site.data.authors[post.author].name}}
36-
{%- else -%}
37-
{{ post.author }}
38-
{%- endif -%}
39-
</span><!--
40-
--><time class="post-list__date" datetime="{{ post.date | date_to_xmlschema }}">
41-
{%- assign date_format = site.date_format -%}
42-
{{ post.date | date: date_format }}</time>
43-
44-
</li>
22+
{% include post-list-item.html %}
4523
{%- endfor -%}
4624

4725
</ul>

0 commit comments

Comments
 (0)