add option to show post excerpts on posts with a title

This commit is contained in:
Pat Dryburgh
2018-08-12 14:04:49 -07:00
parent ed34b49645
commit 4d3d8d3e73
5 changed files with 46 additions and 31 deletions

View File

@ -0,0 +1,13 @@
{% capture excerpt %}
{{ post.excerpt | replace: "<p>", "" | replace: "</p>", "" }}
{% endcapture %}
{% assign excerpt_length = excerpt | size %}
<em class="post-link__excerpt">
{% if excerpt_length > 140 %}
{{ excerpt | truncatewords: 20, '…' }}
{% else %}
{{ excerpt }}
{% endif %}
</em>

View File

@ -1,24 +1,17 @@
{% capture excerpt %}
{{ post.excerpt | replace: "<p>", "" | replace: "</p>", "" }}
{% endcapture %}
{% assign excerpt_length = excerpt | size %}
<li>
<a href="{{ post.url | absolute_url }}" class="post-link">
{% unless post.title == "" %}
<span class="post-title">
{{ post.title }}
</span>
{% else %}
<span class="post-title">
{% if excerpt_length > 140 %}
{{ excerpt | truncatewords: 12, '…' }}
{% else %}
{{ excerpt }}
{% endif %}
</span>
{% endunless %}
<div class="post-link__heading">
{% unless post.title == "" %}
<h1 class="post-link__title">
{{ post.title }}
</h1>
{% else %}
{% include post-excerpt.html %}
{% endunless %}
{% if post.title != "" and site.show_excerpts == true %}
{% include post-excerpt.html %}
{% endif %}
</div>
<span class="post-date">
{{ post.date | date: "%b %-d, '%y" }}
</span>