Skip to content

Commit 6e32c6f

Browse files
authored
Merge branch 'master' into improve-collection-and-category-management
2 parents 0c76e94 + c2462e5 commit 6e32c6f

File tree

6 files changed

+80
-10
lines changed

6 files changed

+80
-10
lines changed

History.markdown

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## HEAD
2+
3+
### Development Fixes
4+
5+
* test: use categories in post (#249)
6+
7+
### Minor Enhancements
8+
9+
* Excerpt only flag (#287)
10+
111
## 0.12.1 / 2019-03-23
212

313
* Release: v0.12.0 (#271)

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,21 @@ feed:
195195
- updates
196196
```
197197

198+
## Excerpt Only flag
199+
200+
Optional flag `excerpt_only` allows you to exclude post content from the Atom feed. Default value is `false` for backward compatibility.
201+
202+
When in `config.yml` is `true` than all posts in feed will be without `<content>` tags.
203+
204+
```yml
205+
feed:
206+
excerpt_only: true
207+
```
208+
209+
The same flag can be used directly in post file. It will be disable `<content>` tag for selected post.
210+
Settings in post file has higher priority than in config file.
211+
212+
198213
## Contributing
199214

200215
1. Fork it (https://github.com/jekyll/jekyll-feed/fork)

lib/jekyll-feed/feed.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@
3838
<published>{{ post.date | date_to_xmlschema }}</published>
3939
<updated>{{ post.last_modified_at | default: post.date | date_to_xmlschema }}</updated>
4040
<id>{{ post.id | absolute_url | xml_escape }}</id>
41-
<content type="html" xml:base="{{ post.url | absolute_url | xml_escape }}">{{ post.content | strip | xml_escape }}</content>
41+
{% assign excerpt_only = post.feed.excerpt_only | default: site.feed.excerpt_only %}
42+
{% unless excerpt_only %}
43+
<content type="html" xml:base="{{ post.url | absolute_url | xml_escape }}">{{ post.content | strip | xml_escape }}</content>
44+
{% endunless %}
4245

4346
{% assign post_author = post.author | default: post.authors[0] | default: site.author %}
4447
{% assign post_author = site.data.authors[post_author] | default: post_author %}

spec/fixtures/_posts/2014-03-04-march-the-fourth.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ tags:
33
- '"/><VADER>'
44
image:
55
path: "/object-image.png"
6-
category: updates
6+
categories: updates jekyll
77
---
88

99
March the fourth!
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
---
2+
feed:
3+
excerpt_only: true
24
---
5+
6+
This content should not be in feed.

spec/jekyll-feed_spec.rb

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
end
4444

4545
it "puts all the posts in the feed.xml file" do
46-
expect(contents).to match "http://example.org/updates/2014/03/04/march-the-fourth.html"
46+
expect(contents).to match "http://example.org/updates/jekyll/2014/03/04/march-the-fourth.html"
4747
expect(contents).to match "http://example.org/news/2014/03/02/march-the-second.html"
4848
expect(contents).to match "http://example.org/news/2013/12/12/dec-the-second.html"
4949
expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html"
@@ -240,7 +240,7 @@
240240
end
241241

242242
it "correctly adds the baseurl to the posts" do
243-
expect(contents).to match "http://example.org/bass/updates/2014/03/04/march-the-fourth.html"
243+
expect(contents).to match "http://example.org/bass/updates/jekyll/2014/03/04/march-the-fourth.html"
244244
expect(contents).to match "http://example.org/bass/news/2014/03/02/march-the-second.html"
245245
expect(contents).to match "http://example.org/bass/news/2013/12/12/dec-the-second.html"
246246
end
@@ -405,7 +405,7 @@
405405
let(:news_feed) { File.read(dest_dir("feed/news.xml")) }
406406

407407
it "outputs the primary feed" do
408-
expect(contents).to match "http://example.org/updates/2014/03/04/march-the-fourth.html"
408+
expect(contents).to match "http://example.org/updates/jekyll/2014/03/04/march-the-fourth.html"
409409
expect(contents).to match "http://example.org/news/2014/03/02/march-the-second.html"
410410
expect(contents).to match "http://example.org/news/2013/12/12/dec-the-second.html"
411411
expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html"
@@ -416,7 +416,7 @@
416416
expect(news_feed).to match '<title type="html">My awesome site | News</title>'
417417
expect(news_feed).to match "http://example.org/news/2014/03/02/march-the-second.html"
418418
expect(news_feed).to match "http://example.org/news/2013/12/12/dec-the-second.html"
419-
expect(news_feed).to_not match "http://example.org/updates/2014/03/04/march-the-fourth.html"
419+
expect(news_feed).to_not match "http://example.org/updates/jekyll/2014/03/04/march-the-fourth.html"
420420
expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
421421
end
422422
end
@@ -436,7 +436,7 @@
436436
let(:news_feed) { File.read(dest_dir("feed/news.xml")) }
437437

438438
it "outputs the primary feed" do
439-
expect(contents).to match "http://example.org/updates/2014/03/04/march-the-fourth.html"
439+
expect(contents).to match "http://example.org/updates/jekyll/2014/03/04/march-the-fourth.html"
440440
expect(contents).to match "http://example.org/news/2014/03/02/march-the-second.html"
441441
expect(contents).to match "http://example.org/news/2013/12/12/dec-the-second.html"
442442
expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html"
@@ -447,7 +447,7 @@
447447
expect(news_feed).to match '<title type="html">My awesome site | News</title>'
448448
expect(news_feed).to match "http://example.org/news/2014/03/02/march-the-second.html"
449449
expect(news_feed).to match "http://example.org/news/2013/12/12/dec-the-second.html"
450-
expect(news_feed).to_not match "http://example.org/updates/2014/03/04/march-the-fourth.html"
450+
expect(news_feed).to_not match "http://example.org/updates/jekyll/2014/03/04/march-the-fourth.html"
451451
expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
452452
end
453453
end
@@ -472,7 +472,7 @@
472472
expect(collection_feed).to match '<title type="html">My awesome site | Collection</title>'
473473
expect(collection_feed).to match "http://example.org/collection/2018-01-01-collection-doc.html"
474474
expect(collection_feed).to match "http://example.org/collection/2018-01-02-collection-category-doc.html"
475-
expect(collection_feed).to_not match "http://example.org/updates/2014/03/04/march-the-fourth.html"
475+
expect(collection_feed).to_not match "http://example.org/updates/jekyll/2014/03/04/march-the-fourth.html"
476476
expect(collection_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
477477
end
478478
end
@@ -525,7 +525,7 @@
525525
expect(news_feed).to match '<title type="html">My awesome site | Collection | News</title>'
526526
expect(news_feed).to match "http://example.org/collection/2018-01-02-collection-category-doc.html"
527527
expect(news_feed).to_not match "http://example.org/collection/2018-01-01-collection-doc.html"
528-
expect(news_feed).to_not match "http://example.org/updates/2014/03/04/march-the-fourth.html"
528+
expect(news_feed).to_not match "http://example.org/updates/jekyll/2014/03/04/march-the-fourth.html"
529529
expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
530530
end
531531
end
@@ -556,4 +556,42 @@
556556
end
557557
end
558558
end
559+
560+
context "excerpt_only flag" do
561+
context "backward compatibility for no excerpt_only flag" do
562+
it "should be in contents" do
563+
expect(contents).to match '<content '
564+
end
565+
end
566+
567+
context "when site.excerpt_only flag is true" do
568+
let(:overrides) do
569+
{ "feed" => { "excerpt_only" => true } }
570+
end
571+
572+
it "should not set any contents" do
573+
expect(contents).to_not match '<content '
574+
end
575+
end
576+
577+
context "when site.excerpt_only flag is false" do
578+
let(:overrides) do
579+
{ "feed" => { "excerpt_only" => false } }
580+
end
581+
582+
it "should be in contents" do
583+
expect(contents).to match '<content '
584+
end
585+
end
586+
587+
context "when post.excerpt_only flag is true" do
588+
let(:overrides) do
589+
{ "feed" => { "excerpt_only" => false } }
590+
end
591+
592+
it "should not be in contents" do
593+
expect(contents).to_not match "This content should not be in feed.</content>"
594+
end
595+
end
596+
end
559597
end

0 commit comments

Comments
 (0)