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" url-pretty: "MyWebsite.com" # eg. "deanattali.com/beautiful-jekyll"
# --- Misc --- # # --- 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 # Fill in your Disqus shortname (NOT the userid) if you want to support Disqus comments
#disqus: "" #disqus: ""

View File

@ -22,8 +22,19 @@ subtitle: This is where I will tell my friends way too much about me
</p> </p>
<div class="post-entry"> <div class="post-entry">
{{ post.excerpt | strip_html | xml_escape | truncatewords: 50 }} {% 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> <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> </div>
{% if post.tags.size > 0 %} {% if post.tags.size > 0 %}