Skip to content

Commit eb7f1af

Browse files
authored
Check post.categories instead of post.category (#357)
Merge pull request 357
1 parent 713f80c commit eb7f1af

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lib/jekyll-feed/feed.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
{% assign posts = site[page.collection] %}
4646
{% endif %}
4747
{% if page.category %}
48-
{% assign posts = posts | where: "category", page.category %}
48+
{% assign posts = posts | where: "categories", page.category %}
4949
{% endif %}
5050
{% unless site.show_drafts %}
5151
{% assign posts = posts | where_exp: "post", "post.draft != true" %}

spec/jekyll-feed_spec.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,11 @@ def to_s
397397
context "with top-level post categories" do
398398
let(:overrides) do
399399
{
400-
"feed" => { "categories" => ["news"] },
400+
"feed" => { "categories" => %w(news jekyll) },
401401
}
402402
end
403-
let(:news_feed) { File.read(dest_dir("feed/news.xml")) }
403+
let(:singular_category_feed) { File.read(dest_dir("feed/news.xml")) }
404+
let(:plural_categories_feed) { File.read(dest_dir("feed/jekyll.xml")) }
404405

405406
it "outputs the primary feed" do
406407
expect(contents).to match "http://example.org/updates/jekyll/2014/03/04/march-the-fourth.html"
@@ -410,12 +411,13 @@ def to_s
410411
expect(contents).to_not match "http://example.org/2016/02/09/a-draft.html"
411412
end
412413

413-
it "outputs the category feed" do
414-
expect(news_feed).to match '<title type="html">My awesome site | News</title>'
415-
expect(news_feed).to match "http://example.org/news/2014/03/02/march-the-second.html"
416-
expect(news_feed).to match "http://example.org/news/2013/12/12/dec-the-second.html"
417-
expect(news_feed).to_not match "http://example.org/updates/jekyll/2014/03/04/march-the-fourth.html"
418-
expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
414+
it "outputs the category feeds" do
415+
expect(singular_category_feed).to match '<title type="html">My awesome site | News</title>'
416+
expect(singular_category_feed).to match "http://example.org/news/2014/03/02/march-the-second.html"
417+
expect(singular_category_feed).to match "March the second!"
418+
expect(plural_categories_feed).to match '<title type="html">My awesome site | News</title>'
419+
expect(plural_categories_feed).to match "http://example.org/updates/jekyll/2014/03/04/march-the-fourth.html"
420+
expect(plural_categories_feed).to match "March the fourth!"
419421
end
420422
end
421423

0 commit comments

Comments
 (0)