File tree 3 files changed +21
-2
lines changed
3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 1
1
source "https://rubygems.org"
2
2
3
3
gem "jekyll"
4
+ gem "nokogiri"
4
5
group :jekyll_plugins do
5
6
gem "jekyll-paginate"
6
7
gem "jekyll-seo-tag"
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ <h3>{{ post.title }}</h3>
19
19
{% include author.html %}
20
20
</ div >
21
21
< hr >
22
- < div class ="snippet snippet-2 ">
23
- < p > {{ post.content | strip_html | truncatewords:50 }}</ p >
22
+ < div class ="snippet ">
23
+ < p > {{ post.content | first_paragraph | strip_html }}</ p >
24
24
</ div >
25
25
</ div >
26
26
</ a >
Original file line number Diff line number Diff line change
1
+ #
2
+ # Jekyll plugin that adds the `first_paragraph` Liquid filter, which returns
3
+ # only the first paragraph of an HTML string.
4
+ #
5
+
6
+ require 'nokogiri'
7
+
8
+
9
+ module Jekyll
10
+ module AssetFilter
11
+ def first_paragraph ( html )
12
+ paragraph = Nokogiri ::HTML ( html ) . css ( 'p' ) . first . to_html
13
+ end
14
+ end
15
+ end
16
+
17
+
18
+ Liquid ::Template . register_filter ( Jekyll ::AssetFilter )
You can’t perform that action at this time.
0 commit comments