Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for categories frontmatter #153

Merged
merged 17 commits into from Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/jekyll-feed/feed.xml
Expand Up @@ -71,9 +71,9 @@
{% endif %}
</author>

{% if post.category %}
<category term="{{ post.category | xml_escape }}" />
{% endif %}
{% for category in post.categories %}
<category term="{{ category | xml_escape }}" />
{% endfor %}

{% for tag in post.tags %}
<category term="{{ tag | xml_escape }}" />
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/_posts/2015-05-12-liquid.md
@@ -1,4 +1,5 @@
---
categories: [first, second, third]
---

{% capture liquidstring %}
Expand Down
13 changes: 13 additions & 0 deletions spec/jekyll-feed_spec.rb
Expand Up @@ -303,6 +303,19 @@
end
end

context "with 'categories' or 'category' or 'tags' key in the front matter" do
let(:feed) { RSS::Parser.parse(contents) }
let(:entry_with_single_category) { feed.items.find { |i| i.title.content == "March The Second" } }
let(:entry_with_multiple_categories) { feed.items.find { |i| i.title.content == "Liquid" } }
let(:entry_with_multiple_categories_and_tags) { feed.items.find { |i| i.title.content == "March The Fourth" } }

it "generates the feed correctly" do
expect(entry_with_single_category.categories.map(&:term)).to eql(%w(news))
expect(entry_with_multiple_categories.categories.map(&:term)).to eql(%w(first second third))
expect(entry_with_multiple_categories_and_tags.categories.map(&:term)).to eql(["updates", "jekyll", "\"/><VADER>"])
end
end

context "changing the file path via collection meta" do
let(:overrides) do
{
Expand Down