Fix #4188: Extract title from filename successfully when dateless.
This commit is contained in:
parent
c0e0159783
commit
1298ba6908
|
@ -155,5 +155,20 @@ Feature: Collections
|
|||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Collections: Jekyll.configuration, Jekyll.escape, Jekyll.sanitized_path, Site#generate, , Site#generate," in "_site/index.html"
|
||||
Then the _site directory should exist
|
||||
And I should see "Collections: Jekyll.configuration, Jekyll.escape, Jekyll.sanitized_path, Site#generate, Initialize, Site#generate, YAML with Dots," in "_site/index.html"
|
||||
|
||||
Scenario: Rendered collection with date/dateless filename
|
||||
Given I have an "index.html" page that contains "Collections: {% for method in site.thanksgiving %}{{ method.title }} {% endfor %}"
|
||||
And I have fixture collections
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
thanksgiving:
|
||||
output: true
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Thanksgiving Black Friday" in "_site/index.html"
|
||||
And I should see "Happy Thanksgiving" in "_site/thanksgiving/2015-11-26-thanksgiving.html"
|
||||
And I should see "Black Friday" in "_site/thanksgiving/black-friday.html"
|
||||
|
|
|
@ -8,7 +8,7 @@ module Jekyll
|
|||
attr_accessor :content, :output
|
||||
|
||||
YAML_FRONT_MATTER_REGEXP = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
|
||||
DATELESS_FILENAME_MATCHER = /^(.*)(\.[^.]+)$/
|
||||
DATELESS_FILENAME_MATCHER = /^(.+\/)*(.*)(\.[^.]+)$/
|
||||
DATE_FILENAME_MATCHER = /^(.+\/)*(\d+-\d+-\d+)-(.*)(\.[^.]+)$/
|
||||
|
||||
# Create a new Document.
|
||||
|
@ -299,6 +299,9 @@ module Jekyll
|
|||
if data['date'].nil? || data['date'].to_i == site.time.to_i
|
||||
merge_data!({"date" => date}, source: "filename")
|
||||
end
|
||||
elsif DATELESS_FILENAME_MATCHER =~ relative_path
|
||||
m, cats, slug, ext = *relative_path.match(DATELESS_FILENAME_MATCHER)
|
||||
data['title'] ||= slug.split('-').select {|w| w.capitalize! || w }.join(' ')
|
||||
end
|
||||
populate_categories
|
||||
populate_tags
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
---
|
||||
Happy {{ page.title }} !
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
---
|
||||
{{ page.title }}
|
Loading…
Reference in New Issue