Add check to only show readme link when there is additional post content not shown on index page. Handles truncate words problems with Chinese and Japanese characters by checking for a manual break using the site excerpt separator. (#110)

This commit is contained in:
Luke Dodge 2016-10-04 21:12:20 -05:00 committed by Dean Attali
parent d614580743
commit 1b668a3223
2 changed files with 15 additions and 2 deletions

View File

@ -81,6 +81,8 @@ share-links-active:
url-pretty: "MyWebsite.com" # eg. "deanattali.com/beautiful-jekyll"
# --- Misc --- #
# Manually break the site excerpt
excerpt_separator: <!--read more-->
# Fill in your Disqus shortname (NOT the userid) if you want to support Disqus comments
#disqus: ""

View File

@ -22,8 +22,19 @@ subtitle: This is where I will tell my friends way too much about me
</p>
<div class="post-entry">
{{ post.excerpt | strip_html | xml_escape | truncatewords: 50 }}
<a href="{{ post.url | prepend: site.baseurl }}" class="post-read-more">[Read&nbsp;More]</a>
{% if post.content contains site.excerpt_separator %}
{{ post.excerpt | strip_html | xml_escape }}
<a href="{{ post.url | prepend: site.baseurl }}" class="post-read-more">[Read&nbsp;More]</a>
{% else %}
{% assign cleaned_content = post.content | strip_html | xml_escape %}
{% assign truncated_content = cleaned_content | truncatewords: 50 %}
{% if truncated_content == cleaned_content %}
{{ cleaned_content }}
{% else %}
{{ truncated_content }}
<a href="{{ post.url | prepend: site.baseurl }}" class="post-read-more">[Read&nbsp;More]</a>
{% endif%}
{% endif %}
</div>
{% if post.tags.size > 0 %}