Skip to content

Commit

Permalink
Allow categories: true to make feeds for all categories
Browse files Browse the repository at this point in the history
  • Loading branch information
jez committed Dec 24, 2022
1 parent a58064c commit c7a137d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ feed:
- updates
```

Or, to generate a feed for all categories:

```yml
feed:
categories: true
```

## Posts limit

By default the plugin limits the number of posts in the feed to 10. Simply define a new limit in your config:
Expand Down Expand Up @@ -193,6 +200,16 @@ feed:
- updates
```

Or pass `categories: true` to generate a feed for all categories:

```yml
feed:
collections:
changes:
path: "/changes.atom"
categories: true
```

## Excerpt Only flag

Optional flag `excerpt_only` allows you to exclude post content from the Atom feed. Default value is `false` for backward compatibility.
Expand Down
11 changes: 10 additions & 1 deletion lib/jekyll-feed/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,16 @@ def collections

@collections = normalize_posts_meta(@collections)
@collections.each_value do |meta|
meta["categories"] = (meta["categories"] || []).to_set
meta_categories = meta["categories"]
for_collection = case meta_categories
when Array
meta_categories
when true
@site.categories.keys
else
[]
end
meta["categories"] = for_collection.to_set
end

@collections
Expand Down
14 changes: 14 additions & 0 deletions spec/jekyll-feed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,20 @@ def to_s
end
end

context "with top-level post categories (using true to mean all)" do
let(:overrides) do
{
"feed" => { "categories" => true }
}
end

it "outputs feeds for all categories" do
site.categories.each_key do |category|
expect(Pathname.new(dest_dir("feed/#{category}.xml"))).to exist
end
end
end

context "with collection-level post categories" do
let(:overrides) do
{
Expand Down

0 comments on commit c7a137d

Please sign in to comment.