File tree Expand file tree Collapse file tree 2 files changed +30
-5
lines changed Expand file tree Collapse file tree 2 files changed +30
-5
lines changed Original file line number Diff line number Diff line change 4040 {% endif %}
4141
4242 {% if page.tags %}
43- {% assign entries = site.tags[page.tags] %}
43+ {% assign posts = site.tags[page.tags] %}
4444 {% else %}
45- {% assign entries = site[page.collection] %}
45+ {% assign posts = site[page.collection] %}
4646 {% endif %}
47- {% assign posts = entries | where_exp: "post", "post.draft != true" | sort: "date" | reverse %}
4847 {% if page.category %}
49- {% assign posts = posts | where: "category",page.category %}
48+ {% assign posts = posts | where: "category", page.category %}
5049 {% endif %}
50+ {% unless site.show_drafts %}
51+ {% assign posts = posts | where_exp: "post", "post.draft != true" %}
52+ {% endunless %}
53+ {% assign posts = posts | sort: "date" | reverse %}
5154 {% assign posts_limit = site.feed.posts_limit | default: 10 %}
5255 {% for post in posts limit: posts_limit %}
5356 <entry {% if post.lang %}{{" " }}xml:lang=" {{ post.lang }}" {% endif %}>
Original file line number Diff line number Diff line change 99 "full_rebuild" => true ,
1010 "source" => source_dir ,
1111 "destination" => dest_dir ,
12- "show_drafts" => true ,
12+ "show_drafts" => false ,
1313 "url" => "http://example.org" ,
1414 "name" => "My awesome site" ,
1515 "author" => {
701701 expect ( contents ) . to match "http://example.org/2016/04/25/author-reference.html"
702702 end
703703 end
704+
705+ context "support drafts" do
706+ context "with disable show_drafts option" do
707+ let ( :overrides ) do
708+ { "show_drafts" => false }
709+ end
710+
711+ it "should not be draft post" do
712+ expect ( contents ) . to_not match "a-draft.html"
713+ end
714+ end
715+
716+ context "with enable show_drafts option" do
717+ let ( :overrides ) do
718+ { "show_drafts" => true }
719+ end
720+
721+ it "should be draft post" do
722+ expect ( contents ) . to match "a-draft.html"
723+ end
724+ end
725+ end
704726end
You can’t perform that action at this time.
0 commit comments