Coder Social home page Coder Social logo

Exclude Drafts from feed about jekyll-feed HOT 15 CLOSED

jekyll avatar jekyll commented on May 18, 2024
Exclude Drafts from feed

from jekyll-feed.

Comments (15)

pathawks avatar pathawks commented on May 18, 2024

I have also published a post “publically” for the purpose of sending it to somebody to proofread.

I’m not sure if future date is the way to do this, seems like that could lead to some trouble if time zones or something caused Jekyll to improperly exclude a new post from the feed.

Perhaps a way to explicitly exclude a post from the feed, similar to sitemap: false?

from jekyll-feed.

jeremiemartinez avatar jeremiemartinez commented on May 18, 2024

So we could have something like: feed: false that could be added to the frontmatter of each post and then filtered in the for loop in feed.xml. Is that what you mean ? It would also be a good solution since I understand your concerns about time zones.

from jekyll-feed.

pathawks avatar pathawks commented on May 18, 2024

So we could have something like: feed: false that could be added to the frontmatter of each post and then filtered in the for loop in feed.xml. Is that what you mean ?

👍

from jekyll-feed.

benbalter avatar benbalter commented on May 18, 2024

@jeremiemartinez how do you prevent future posts from appearing in your site's human-readable index?

I'm wondering if rather than have the user specify the feature they want ("don't include this in the sitemap", "don't include this in the feed"), the user should expose intend ("this shouldn't be public"), and the two plugins should respond accordingly.

from jekyll-feed.

jeremiemartinez avatar jeremiemartinez commented on May 18, 2024

@benbalter Well, my approach is very similar that the one advised by @pathawks. However, don't judge me, this is not the best code I wrote...

First, I add future: true to my _config.yml.
Then, I declare in the frontmatter of my post: public: 1
Finally, in my index.html, I loop and filter:

{% for post in paginator.posts %}
   {% if post.public != 1  %}
        […]
   {% endif %}
 {% endfor %}

Your idea about a public flag that could be used for every plugin is great but it would require to directly modify jekyll to expose such an API I guess :/

from jekyll-feed.

pathawks avatar pathawks commented on May 18, 2024

Jekyll has a Drafts feature already: is there any way in Liquid to detect if a post is a draft?

I can think of multiple reasons why a public page/post should be excluded from a sitemap (even if not excluded from the public view of a site), but the only reason I can think of to exclude a post from the site feed is if it is just a draft snd not yet “public.”

I am just trying to think through this aloud.

from jekyll-feed.

jeremiemartinez avatar jeremiemartinez commented on May 18, 2024

Draft would be a good solution but it seems that Github does not deploy drafts so I cannot ask friends for proofreading unfortunately.

from jekyll-feed.

jeremiemartinez avatar jeremiemartinez commented on May 18, 2024

Sorry I am completely wrong with my last comment. Just need to add show_drafts flag to my _config.yml. So knowing if a post is a draft matches our need.

from jekyll-feed.

pathawks avatar pathawks commented on May 18, 2024

I wasn’t thinking about GitHub Pages. That makes things a bit trickier, doesn’t it.

from jekyll-feed.

jeremiemartinez avatar jeremiemartinez commented on May 18, 2024

Well, as I corrected in my previous comment, with show_drafts Github Pages does work.

I looked for a way to know whether a post is a draft or not. We can with something like:

{% if post.draft == false %}

Or

{% unless post.draft %}

What do you think about this solution?

from jekyll-feed.

KingScooty avatar KingScooty commented on May 18, 2024
{% for post in site.posts %}
    {% unless post.draft %}
    {% endunless %}
{% endfor %}

from jekyll-feed.

jeremiemartinez avatar jeremiemartinez commented on May 18, 2024

Fixed by #95.

from jekyll-feed.

jeremiemartinez avatar jeremiemartinez commented on May 18, 2024

Hey guys, any idea about a release date ? I would love to include this change in my current project!

from jekyll-feed.

parkr avatar parkr commented on May 18, 2024

@jeremiemartinez v0.5.0 was just released. 😄

from jekyll-feed.

jeremiemartinez avatar jeremiemartinez commented on May 18, 2024

Great news ! Thanks :)

from jekyll-feed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.