Permalink
Browse files

Dont write static files from unrendered collection (#7410)

Merge pull request 7410
  • Loading branch information...
ashmaroli authored and jekyllbot committed Jan 3, 2019
1 parent be78b42 commit 5d144beb00f6a795324b5e997bcc0fc810f63442
Showing with 9 additions and 1 deletion.
  1. +5 −0 features/collections.feature
  2. +4 −1 lib/jekyll/static_file.rb
@@ -6,16 +6,20 @@ Feature: Collections
Scenario: Unrendered collection
Given I have an "index.html" page that contains "Collections: {{ site.methods }}"
And I have fixture collections
And I have a "_methods/static-file.txt" file that contains "Static Content {{ site.title }}"
And I have a configuration file with "collections" set to "['methods']"
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
But the _site/methods directory should not exist
And the "_site/methods/configuration.html" file should not exist
And the "_site/methods/static-file.txt" file should not exist

Scenario: Rendered collection
Given I have an "index.html" page that contains "Collections: output => {{ site.collections[0].output }} label => {{ site.collections[0].label }}"
And I have an "collection_metadata.html" page that contains "Methods metadata: {{ site.collections[0].foo }} {{ site.collections[0] }}"
And I have fixture collections
And I have a "_methods/static-file.txt" file that contains "Static Content {{ site.title }}"
And I have a "_config.yml" file with content:
"""
collections:
@@ -30,6 +34,7 @@ Feature: Collections
And I should see "label => methods" in "_site/index.html"
And I should see "Methods metadata: bar" in "_site/collection_metadata.html"
And I should see "<p>Whatever: foo.bar</p>" in "_site/methods/configuration.html"
And I should see "Static Content {{ site.title }}" in "_site/methods/static-file.txt"

Scenario: Rendered collection at a custom URL
Given I have an "index.html" page that contains "Collections: {{ site.collections }}"
@@ -86,7 +86,10 @@ def modified?
# Returns true unless the defaults for the destination path from
# _config.yml contain `published: false`.
def write?
defaults.fetch("published", true)
publishable = defaults.fetch("published", true)
return publishable unless @collection

publishable && @collection.write?
end

# Write the static file to the destination directory (if modified).

0 comments on commit 5d144be

Please sign in to comment.