Dont write static files from unrendered collection (#7410)
Merge pull request 7410
This commit is contained in:
parent
be78b4246c
commit
5d144beb00
|
@ -6,16 +6,20 @@ Feature: Collections
|
||||||
Scenario: Unrendered collection
|
Scenario: Unrendered collection
|
||||||
Given I have an "index.html" page that contains "Collections: {{ site.methods }}"
|
Given I have an "index.html" page that contains "Collections: {{ site.methods }}"
|
||||||
And I have fixture collections
|
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']"
|
And I have a configuration file with "collections" set to "['methods']"
|
||||||
When I run jekyll build
|
When I run jekyll build
|
||||||
Then I should get a zero exit status
|
Then I should get a zero exit status
|
||||||
And the _site directory should exist
|
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/configuration.html" file should not exist
|
||||||
|
And the "_site/methods/static-file.txt" file should not exist
|
||||||
|
|
||||||
Scenario: Rendered collection
|
Scenario: Rendered collection
|
||||||
Given I have an "index.html" page that contains "Collections: output => {{ site.collections[0].output }} label => {{ site.collections[0].label }}"
|
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 an "collection_metadata.html" page that contains "Methods metadata: {{ site.collections[0].foo }} {{ site.collections[0] }}"
|
||||||
And I have fixture collections
|
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:
|
And I have a "_config.yml" file with content:
|
||||||
"""
|
"""
|
||||||
collections:
|
collections:
|
||||||
|
@ -30,6 +34,7 @@ Feature: Collections
|
||||||
And I should see "label => methods" in "_site/index.html"
|
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 "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 "<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
|
Scenario: Rendered collection at a custom URL
|
||||||
Given I have an "index.html" page that contains "Collections: {{ site.collections }}"
|
Given I have an "index.html" page that contains "Collections: {{ site.collections }}"
|
||||||
|
|
|
@ -86,7 +86,10 @@ module Jekyll
|
||||||
# Returns true unless the defaults for the destination path from
|
# Returns true unless the defaults for the destination path from
|
||||||
# _config.yml contain `published: false`.
|
# _config.yml contain `published: false`.
|
||||||
def write?
|
def write?
|
||||||
defaults.fetch("published", true)
|
publishable = defaults.fetch("published", true)
|
||||||
|
return publishable unless @collection
|
||||||
|
|
||||||
|
publishable && @collection.write?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Write the static file to the destination directory (if modified).
|
# Write the static file to the destination directory (if modified).
|
||||||
|
|
Loading…
Reference in New Issue