From f4d139d2d01045bc59aa85f67758ebd8b83f8783 Mon Sep 17 00:00:00 2001
From: Luke Dodge
Date: Fri, 7 Oct 2016 04:56:48 -0500
Subject: [PATCH] Fix show/hide of Read Me link on index page (#111)
---
_config.yml | 4 ++++
index.html | 13 +++++--------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/_config.yml b/_config.yml
index a91b4bc..aacd69d 100644
--- a/_config.yml
+++ b/_config.yml
@@ -90,6 +90,10 @@ url-pretty: "MyWebsite.com" # eg. "deanattali.com/beautiful-jekyll"
# Facebook App ID
# fb_app_id: ""
+# Excerpt Word Length
+# Truncates the excerpt to the specified number of words on the index page
+excerpt_length: 50
+
# --- Don't need to touch anything below here (but you can if you want) --- #
# Output options (more information on Jekyll's site)
diff --git a/index.html b/index.html
index e7ffb0d..d846f02 100644
--- a/index.html
+++ b/index.html
@@ -22,19 +22,16 @@ subtitle: This is where I will tell my friends way too much about me
- {% assign cleaned_content = post.excerpt | strip_html | xml_escape %}
- {% assign truncated_content = cleaned_content | truncatewords: 50 %}
- {% if truncated_content == cleaned_content %}
- {{ cleaned_content }}
- {% else %}
- {{ truncated_content }}
+ {{ post.excerpt | strip_html | xml_escape | truncatewords: site.excerpt_length }}
+ {% assign excerpt_word_count = post.excerpt | number_of_words %}
+ {% if post.content != post.excerpt or excerpt_word_count > site.excerpt_length %}
[Read More]
- {% endif%}
+ {% endif %}
{% if post.tags.size > 0 %}