Skip to content

Commit

Permalink
Filter out hidden posts
Browse files Browse the repository at this point in the history
  • Loading branch information
bkoprucu committed Jan 31, 2024
1 parent f321e1c commit efbd388
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/jekyll-feed/feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
{% unless site.show_drafts %}
{% assign posts = posts | where_exp: "post", "post.draft != true" %}
{% endunless %}
{% assign posts = posts | where_exp: "post", "post.hidden == nil or post.hidden == false" %}
{% assign posts = posts | sort: "date" | reverse %}
{% assign posts_limit = site.feed.posts_limit | default: 10 %}
{% for post in posts limit: posts_limit %}
Expand Down
5 changes: 5 additions & 0 deletions spec/fixtures/_posts/2024-01-31-hidden-sample.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
hidden: 1
---

# A hidden post
3 changes: 3 additions & 0 deletions spec/jekyll-feed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
expect(contents).to match "http://example.org/news/2013/12/12/dec-the-second.html"
expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html"
expect(contents).to_not match "http://example.org/2016/02/09/a-draft.html"
expect(contents).to_not match "http://example.org/2024/01/31/hidden-sample.html"
end

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

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

it "outputs the category feed" do
Expand Down

0 comments on commit efbd388

Please sign in to comment.