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

@ -35,4 +35,6 @@ markdown: kramdown
# - vendor/bundle/
# - vendor/cache/
# - vendor/gems/
# - vendor/ruby/
# - vendor/ruby/
show_excerpts: true

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>

View File

@ -38,6 +38,14 @@ h6 {
text-align: center;
}
em {
font-style: italic;
}
strong {
font-weight: bold;
}
a {
color: $text-color;
}

View File

@ -9,27 +9,26 @@
flex-direction: column-reverse;
text-decoration: none;
padding: .25em 0;
.post-title {
display: block;
padding: .25em 0;
}
&:hover .post-title,
&:focus .post-title {
text-decoration: underline;
}
@media (min-width: $on-tablet) {
display: flex;
flex-direction: row;
justify-content: space-between;
.post-title {
margin-right: 4em;
}
.post-date {
margin-left: auto;
}
}
}
.post-link__heading {
display: block;
margin-right: 4em;
padding: .25em 0;
}
.post-link__title + .post-link__excerpt {
opacity: .6;
}
.post-pagination {
margin-top: 4rem;
font-size: .75em;