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

@ -36,3 +36,5 @@ markdown: kramdown
# - vendor/cache/ # - vendor/cache/
# - vendor/gems/ # - 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> <li>
<a href="{{ post.url | absolute_url }}" class="post-link"> <a href="{{ post.url | absolute_url }}" class="post-link">
<div class="post-link__heading">
{% unless post.title == "" %} {% unless post.title == "" %}
<span class="post-title"> <h1 class="post-link__title">
{{ post.title }} {{ post.title }}
</span> </h1>
{% else %} {% else %}
<span class="post-title"> {% include post-excerpt.html %}
{% if excerpt_length > 140 %}
{{ excerpt | truncatewords: 12, '…' }}
{% else %}
{{ excerpt }}
{% endif %}
</span>
{% endunless %} {% endunless %}
{% if post.title != "" and site.show_excerpts == true %}
{% include post-excerpt.html %}
{% endif %}
</div>
<span class="post-date"> <span class="post-date">
{{ post.date | date: "%b %-d, '%y" }} {{ post.date | date: "%b %-d, '%y" }}
</span> </span>

View File

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

View File

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