diff options
| author | davidtsadler <davidtsadler@googlemail.com> | 2012-01-05 23:31:30 +0000 |
|---|---|---|
| committer | davidtsadler <davidtsadler@googlemail.com> | 2012-01-05 23:31:30 +0000 |
| commit | d46501e18b795d9bf41f229298810bffa1d8e520 (patch) | |
| tree | d44214d722293708d3c47677ff6abe3cb92433c0 /_site_build | |
| parent | c76802130c1541fb03f3c9170726aedf25aae599 (diff) | |
Replace ExcerptFilter with TruncateFilter.
Diffstat (limited to '_site_build')
| -rw-r--r-- | _site_build/_includes/post_excerpt.html | 5 | ||||
| -rw-r--r-- | _site_build/_plugins/posts.rb | 10 |
2 files changed, 8 insertions, 7 deletions
diff --git a/_site_build/_includes/post_excerpt.html b/_site_build/_includes/post_excerpt.html index a8ef58e..1caf4d5 100644 --- a/_site_build/_includes/post_excerpt.html +++ b/_site_build/_includes/post_excerpt.html @@ -1,8 +1,7 @@ <article class="excerpt"> <header> - <h1>{{ post.title }}</h1> + <h1><a href="{{ post.url }}" target="_self" title="{{ post.title }}">{{ post.title }}</a></h1> <time datetime="{{ post.date | date: '%Y-%m-%d' }}" pubdate>{{ post.date | date: '%A' }} {{ post.date | ordinalize }} {{ post.date | date: '%B, %Y' }}</time> </header> - {{ post.content | text_excerpt }} - <a href="{{ post.url }}" target="_self" title="{{ post.title }}">Click to continue reading »</a> + {{ post.content | truncate }} </article> diff --git a/_site_build/_plugins/posts.rb b/_site_build/_plugins/posts.rb index 58d0128..75c1c18 100644 --- a/_site_build/_plugins/posts.rb +++ b/_site_build/_plugins/posts.rb @@ -1,9 +1,11 @@ +require 'sanitize' + module Jekyll - module ExcerptFilter - def text_excerpt(text) - text.split(@context.registers[:site].config['excerpt_tag']).first + module TruncateFilter + def truncate(html, num_characters = 1000, indicator = ' [...]') + '<p>' << Sanitize.clean(html).slice(Regexp.new(".{1,#{num_characters}}( |$)")).chomp(' ') << indicator << '</p>' end end end -Liquid::Template.register_filter(Jekyll::ExcerptFilter) +Liquid::Template.register_filter(Jekyll::TruncateFilter) |
