Allow extensionless document in a strict site (#7950)
Merge pull request 7950
This commit is contained in:
parent
f451129e5a
commit
f69471cb4a
|
@ -624,3 +624,36 @@ Feature: Collections
|
|||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "I have no front matter." in "_site/methods/extensionless_static_file"
|
||||
|
||||
Scenario: Rendered collection with an extensionless document
|
||||
Given I have fixture collections
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
methods:
|
||||
output: true
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "I have no file extension but I should still be a part of the collection." in "_site/methods/collection/entries"
|
||||
|
||||
Scenario: Rendered collection with an extensionless document in a strict site
|
||||
Given I have fixture collections
|
||||
And I have a _posts directory
|
||||
And I have an "_posts/2019-12-26-extensioned.md" file that contains "Hello!"
|
||||
And I have an "_posts/2019-12-26-extensionless" file that contains "Aloha!"
|
||||
And I have an "index.md" page that contains "{{ site.posts | map: 'title' }}"
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
strict_front_matter: true
|
||||
collections:
|
||||
methods:
|
||||
output: true
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "I have no file extension but I should still be a part of the collection." in "_site/methods/collection/entries"
|
||||
And I should see "Extensioned" in "_site/index.html"
|
||||
But I should not see "Extensionless" in "_site/index.html"
|
||||
|
|
|
@ -498,6 +498,7 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def populate_title
|
||||
if relative_path =~ DATE_FILENAME_MATCHER
|
||||
date, slug, ext = Regexp.last_match.captures
|
||||
|
@ -505,6 +506,10 @@ module Jekyll
|
|||
elsif relative_path =~ DATELESS_FILENAME_MATCHER
|
||||
slug, ext = Regexp.last_match.captures
|
||||
end
|
||||
# `slug` will be nil for documents without an extension since the regex patterns
|
||||
# above tests for an extension as well.
|
||||
# In such cases, assign `basename_without_ext` as the slug.
|
||||
slug ||= basename_without_ext
|
||||
|
||||
# slugs shouldn't end with a period
|
||||
# `String#gsub!` removes all trailing periods (in comparison to `String#chomp!`)
|
||||
|
@ -516,6 +521,7 @@ module Jekyll
|
|||
data["slug"] ||= slug
|
||||
data["ext"] ||= ext
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
def modify_date(date)
|
||||
if !data["date"] || data["date"].to_i == site.time.to_i
|
||||
|
|
Loading…
Reference in New Issue