From 81e4e1d8f4a0bcba46380b719c7afa1fa2261955 Mon Sep 17 00:00:00 2001 From: Daniel Schauenberg Date: Sat, 22 Mar 2014 19:52:10 -0400 Subject: [PATCH] add support for unpublished drafts I keep all my ideas for blog posts as drafts in my draft folder. However I'm only really working on a couple at once. This let's me mark drafts that I'm not working on right now as unpublished so they don't clutter the site while I'm checking on the other drafts. --- features/drafts.feature | 11 +++++++++++ lib/jekyll/site.rb | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/features/drafts.feature b/features/drafts.feature index 1bf60303..2c819658 100644 --- a/features/drafts.feature +++ b/features/drafts.feature @@ -24,6 +24,17 @@ Feature: Draft Posts Then the _site directory should exist And the "_site/recipe.html" file should not exist + Scenario: Don't preview a draft that is not published + Given I have a configuration file with "permalink" set to "none" + And I have an "index.html" page that contains "Totally index" + And I have a _drafts directory + And I have the following draft: + | title | date | layout | published | content | + | Recipe | 2009-03-27 | default | false | Not baked yet. | + When I run jekyll with drafts + Then the _site directory should exist + And the "_site/recipe.html" file should not exist + Scenario: Use page.path variable Given I have a configuration file with "permalink" set to "none" And I have a _drafts directory diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 393577e9..a285a053 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -186,7 +186,9 @@ module Jekyll drafts = read_content(dir, '_drafts', Draft) drafts.each do |draft| - aggregate_post_info(draft) + if draft.published? + aggregate_post_info(draft) + end end end