algolia / jekyll-algolia

Add fast and relevant search to your Jekyll site
https://community.algolia.com/jekyll-algolia/
MIT License
214 stars 35 forks source link

Expose --future and --drafts options #173

Closed leviem1 closed 3 years ago

leviem1 commented 3 years ago

Exposes the --future and --drafts options to the jekyll algolia command.

This works out quite nicely since these values end up just getting passed to the underlying site as it normally would with something like a jekyll build.

Could use testing, but this is my first Ruby commit, so I barely know where to begin. I tested manually on my machine, but that's by no means in-depth. If you tell me how, I'll do my due diligence, unless you just want to test yourself (I can be slow to respond).

Haroenv commented 3 years ago

Thanks for your PR @leviem1. Could you explain the situation in which you want to index draft posts? Couldn't you just make the post you want to see as not draft? Just wanting to understand the motivation behind the PR :)

leviem1 commented 3 years ago

I kinda figured "why not" since I was adding future anyways. It'd help on my test site where I'm using a separate test index and I still want to be able to search them (and be able to see them on my homepage) while they're being written.

The motivation for the future part is because I'm trying to run this on GitHub Actions, and it's difficult to work with the time zone differences. It's pretty hard to tell when something will actually get indexed and this just removes the entire issue.

Haroenv commented 3 years ago

You mean that when you write a post that gets published now, but GitHub actions thinks it's in the future? You can set the timezone there actually to be your local one: https://github.com/marketplace/actions/set-timezone

I think this might still make sense, the reason I'm asking is because I'll need to find the right person who can review and test this, we don't have any deploys of Jekyll in Algolia anymore

leviem1 commented 3 years ago

I think you got it.

When I publish something, the GitHub Action servers are behind my current time, which causes jekyll algolia to skip some posts. The only reason that the posts actually got rendered is because GitHub Pages uses the future flag internally when building sites as a workaround for this very issue. Besides that, sometimes we publish articles ahead of when they're actually dated when we have schedule conflicts.

The drafts are a bit more difficult to justify. We like to see how our site will look by publishing drafts prior to when they actually go live, and we do this in an entirely separate environment. This works very well with our review and approval processes.

IMO if Jekyll lets you render something, you should be able to index it. In fact, the first iteration of this plugin supported these options. These flags are optional, so there shouldn't be any changes in behavior for those who are already using the plugin. In short, there's not very many arguments for why this shouldn't be an option.

If there's anything I can do to help test this, let me know where to get started and I'll do my best. I'd love to get this into master so I don't have to figure out how to publish my fork on RubyGems.

Haroenv commented 3 years ago

released under 1.7.0, thanks for your contribution @leviem1 !!