Skip to content

Commit f4d139d

Browse files
lrdodgedaattali
authored andcommitted
Fix show/hide of Read Me link on index page (daattali#111)
1 parent dfb1c61 commit f4d139d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

_config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ url-pretty: "MyWebsite.com" # eg. "deanattali.com/beautiful-jekyll"
9090
# Facebook App ID
9191
# fb_app_id: ""
9292

93+
# Excerpt Word Length
94+
# Truncates the excerpt to the specified number of words on the index page
95+
excerpt_length: 50
96+
9397
# --- Don't need to touch anything below here (but you can if you want) --- #
9498

9599
# Output options (more information on Jekyll's site)

index.html

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,16 @@ <h3 class="post-subtitle">
2222
</p>
2323

2424
<div class="post-entry">
25-
{% assign cleaned_content = post.excerpt | strip_html | xml_escape %}
26-
{% assign truncated_content = cleaned_content | truncatewords: 50 %}
27-
{% if truncated_content == cleaned_content %}
28-
{{ cleaned_content }}
29-
{% else %}
30-
{{ truncated_content }}
25+
{{ post.excerpt | strip_html | xml_escape | truncatewords: site.excerpt_length }}
26+
{% assign excerpt_word_count = post.excerpt | number_of_words %}
27+
{% if post.content != post.excerpt or excerpt_word_count > site.excerpt_length %}
3128
<a href="{{ post.url | prepend: site.baseurl }}" class="post-read-more">[Read&nbsp;More]</a>
32-
{% endif%}
29+
{% endif %}
3330
</div>
3431

3532
{% if post.tags.size > 0 %}
3633
<div class="blog-tags">
37-
Tags:
34+
Tags:
3835
{% if site.link-tags %}
3936
{% for tag in post.tags %}
4037
<a href="{{ site.baseurl }}/tag/{{ tag }}">{{ tag }}</a>

0 commit comments

Comments
 (0)