Merge pull request #954 from maul-esel/liquid-override-path
Allow overriding "path" in YAML frontmatter
This commit is contained in:
		
						commit
						47653381b1
					
				|  | @ -168,6 +168,15 @@ Feature: Post data | |||
|       | dir | dir/        | | ||||
|       | dir/nested | dir/nested/ | | ||||
| 
 | ||||
|   Scenario: Override page.path variable | ||||
|     Given I have a _posts directory | ||||
|     And I have the following post: | ||||
|       | title    | date      | path               | content                      | | ||||
|       | override | 4/12/2013 | override-path.html | Custom path: {{ page.path }} | | ||||
|     When I run jekyll | ||||
|     Then the _site directory should exist | ||||
|     And I should see "Custom path: override-path.html" in "_site/2013/04/12/override.html" | ||||
| 
 | ||||
|   Scenario: Disable a post from being published | ||||
|     Given I have a _posts directory | ||||
|     And I have an "index.html" file that contains "Published!" | ||||
|  |  | |||
|  | @ -22,6 +22,12 @@ Feature: Site data | |||
|       | dir | dir/about.html | | ||||
|       | dir/nested | dir/nested/page.html | | ||||
| 
 | ||||
|   Scenario: Override page.path | ||||
|     Given I have an "override.html" page with path "custom-override.html" that contains "Custom path: {{ page.path }}" | ||||
|     When I run jekyll | ||||
|     Then the _site directory should exist | ||||
|     And I should see "Custom path: custom-override.html" in "_site/override.html" | ||||
| 
 | ||||
|   Scenario: Use site.time variable | ||||
|     Given I have an "index.html" page that contains "{{ site.time }}" | ||||
|     When I run jekyll | ||||
|  |  | |||
|  | @ -66,7 +66,7 @@ Given /^I have the following (draft|post)s?(?: (.*) "(.*)")?:$/ do |status, dire | |||
|     end | ||||
| 
 | ||||
|     matter_hash = {} | ||||
|     %w(title layout tag tags category categories published author).each do |key| | ||||
|     %w(title layout tag tags category categories published author path).each do |key| | ||||
|       matter_hash[key] = post[key] if post[key] | ||||
|     end | ||||
|     matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join.chomp | ||||
|  |  | |||
|  | @ -125,7 +125,7 @@ module Jekyll | |||
|       self.data.deep_merge({ | ||||
|         "url"        => self.url, | ||||
|         "content"    => self.content, | ||||
|         "path"       => File.join(@dir, @name).sub(/\A\//, '') }) | ||||
|         "path"       => self.data['path'] || File.join(@dir, @name).sub(/\A\//, '') }) | ||||
|     end | ||||
| 
 | ||||
|     # Obtain destination path. | ||||
|  |  | |||
|  | @ -287,7 +287,7 @@ module Jekyll | |||
|         "tags"       => self.tags, | ||||
|         "content"    => self.content, | ||||
|         "excerpt"    => self.excerpt, | ||||
|         "path"       => File.join(@dir, '_posts', @name).sub(/\A\//, '') }) | ||||
|         "path"       => self.data['path'] || File.join(@dir, '_posts', @name).sub(/\A\//, '') }) | ||||
|     end | ||||
| 
 | ||||
|     # Returns the shorthand String identifier of this Post. | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue