Skip to content

Commit

Permalink
Add check to only show readme link when there is additional post cont…
Browse files Browse the repository at this point in the history
…ent 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. (daattali#110)
  • Loading branch information
lrdodge authored and daattali committed Oct 5, 2016
1 parent 70dba43 commit fee36a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
Expand Down
15 changes: 13 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,19 @@ <h3 class="post-subtitle">
</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 %}
Expand Down

0 comments on commit fee36a6

Please sign in to comment.