Skip to content

Commit d399dbf

Browse files
committed
Filter out hidden posts
1 parent f321e1c commit d399dbf

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

lib/jekyll-feed/feed.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
{% unless site.show_drafts %}
5151
{% assign posts = posts | where_exp: "post", "post.draft != true" %}
5252
{% endunless %}
53+
{% assign posts = posts | where_exp: "post", "post.hidden == nil or post.hidden == false" %}
5354
{% assign posts = posts | sort: "date" | reverse %}
5455
{% assign posts_limit = site.feed.posts_limit | default: 10 %}
5556
{% for post in posts limit: posts_limit %}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
hidden: 1
3+
---
4+
5+
# A hidden post

spec/jekyll-feed_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
expect(contents).to match "http://example.org/news/2013/12/12/dec-the-second.html"
5151
expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html"
5252
expect(contents).to_not match "http://example.org/2016/02/09/a-draft.html"
53+
expect(contents).to_not match "http://example.org/2024/01/31/hidden-sample.html"
5354
end
5455

5556
it "does not include assets or any static files that aren't .html" do
@@ -411,6 +412,7 @@ def to_s
411412
expect(contents).to match "http://example.org/news/2013/12/12/dec-the-second.html"
412413
expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html"
413414
expect(contents).to_not match "http://example.org/2016/02/09/a-draft.html"
415+
expect(contents).to_not match "http://example.org/2024/01/31/hidden-sample.html"
414416
end
415417

416418
it "outputs the category feeds" do
@@ -443,6 +445,7 @@ def to_s
443445
expect(contents).to match "http://example.org/news/2013/12/12/dec-the-second.html"
444446
expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html"
445447
expect(contents).to_not match "http://example.org/2016/02/09/a-draft.html"
448+
expect(contents).to_not match "http://example.org/2024/01/31/hidden-sample.html"
446449
end
447450

448451
it "outputs the category feed" do

0 commit comments

Comments
 (0)