diff --git a/README.md b/README.md index e4f83f6d..dc7dc839 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,8 @@ Additionally, the plugin will use the following values, if present in a post's Y * `description` - A short description of the post. +* `hidden` - When set to true, the post will still be generated by Jekyll, but excluded from the feed, preventing it from appearing in feed readers. + ### Author information *TL;DR: In most cases, put `author: [your name]` in the document's front matter, for sites with multiple authors. If you need something more complicated, read on.* diff --git a/lib/jekyll-feed/feed.xml b/lib/jekyll-feed/feed.xml index 661200b4..c86e26d9 100644 --- a/lib/jekyll-feed/feed.xml +++ b/lib/jekyll-feed/feed.xml @@ -66,6 +66,7 @@ {% unless site.show_drafts %} {% assign posts = posts | where_exp: "post", "post.draft != true" %} {% endunless %} + {% assign posts = posts | where_exp: "post", "post.hidden != true" %} {% assign posts = posts | sort: "date" | reverse %} {% assign posts_limit = site.feed.posts_limit | default: 10 %} {% assign cdata_end_token = "]]>" %} diff --git a/spec/fixtures/_posts/2024-01-31-hidden-sample.md b/spec/fixtures/_posts/2024-01-31-hidden-sample.md new file mode 100644 index 00000000..444d3e48 --- /dev/null +++ b/spec/fixtures/_posts/2024-01-31-hidden-sample.md @@ -0,0 +1,5 @@ +--- +hidden: true +--- + +# A hidden post \ No newline at end of file diff --git a/spec/jekyll-feed_spec.rb b/spec/jekyll-feed_spec.rb index 6f5d58d0..61f82731 100644 --- a/spec/jekyll-feed_spec.rb +++ b/spec/jekyll-feed_spec.rb @@ -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 @@ -431,6 +432,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 @@ -463,6 +465,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