Skip to content

Commit 388b509

Browse files
committed
Allow categories: true to make feeds for all categories
1 parent 038265a commit 388b509

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ feed:
153153
- updates
154154
```
155155

156+
Or, to generate a feed for all categories:
157+
158+
```yml
159+
feed:
160+
categories: true
161+
```
162+
156163
## Posts limit
157164

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

203+
Or pass `categories: true` to generate a feed for all categories:
204+
205+
```yml
206+
feed:
207+
collections:
208+
changes:
209+
path: "/changes.atom"
210+
categories: true
211+
```
212+
196213
## Excerpt Only flag
197214

198215
Optional flag `excerpt_only` allows you to exclude post content from the Atom feed. Default value is `false` for backward compatibility.

lib/jekyll-feed/generator.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,16 @@ def collections
6969

7070
@collections = normalize_posts_meta(@collections)
7171
@collections.each_value do |meta|
72-
meta["categories"] = (meta["categories"] || []).to_set
72+
meta_categories = meta["categories"]
73+
for_collection = case meta_categories
74+
when Array
75+
meta_categories
76+
when true
77+
@site.categories.keys
78+
else
79+
[]
80+
end
81+
meta["categories"] = for_collection.to_set
7382
end
7483

7584
@collections

spec/jekyll-feed_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,20 @@ def to_s
423423
end
424424
end
425425

426+
context "with top-level post categories (using true to mean all)" do
427+
let(:overrides) do
428+
{
429+
"feed" => { "categories" => true }
430+
}
431+
end
432+
433+
it "outputs feeds for all categories" do
434+
site.categories.each_key do |category|
435+
expect(Pathname.new(dest_dir("feed/#{category}.xml"))).to exist
436+
end
437+
end
438+
end
439+
426440
context "with collection-level post categories" do
427441
let(:overrides) do
428442
{

0 commit comments

Comments
 (0)