From 40e44a2051a9387dd68be9ff98574d130c2dd9d6 Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Sat, 13 Apr 2013 18:45:40 +0200 Subject: [PATCH 1/2] do not force the permalink to be a dir if it ends on .html Fixes #798. --- lib/jekyll/post.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 5ea56898..7e01f635 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -255,7 +255,7 @@ module Jekyll def destination(dest) # The url needs to be unescaped in order to preserve the correct filename path = File.join(dest, CGI.unescape(self.url)) - path = File.join(path, "index.html") if template[/\.html$/].nil? + path = File.join(path, "index.html") if path[/\.html$/].nil? path end From c0dfe3165c85e7720b8639d4add697ea914ceba9 Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Sun, 14 Apr 2013 09:47:40 +0200 Subject: [PATCH 2/2] test per-post permalinks Add tests for setting a permalink on a post (in YAML frontmatter), both the "old way" (generating an index.html) and with an .html ex- tension. --- features/permalinks.feature | 20 ++++++++++++++++++++ features/step_definitions/jekyll_steps.rb | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/features/permalinks.feature b/features/permalinks.feature index 050e75c3..0b42726a 100644 --- a/features/permalinks.feature +++ b/features/permalinks.feature @@ -63,3 +63,23 @@ Feature: Fancy permalinks When I run jekyll Then the _site directory should exist And I should see "Totally custom." in "_site/03-27-2009/custom-permalink-schema.html" + + Scenario: Use per-post permalink + Given I have a _posts directory + And I have the following post: + | title | date | permalink | content | + | Some post | 4/14/2013 | /custom/posts/1 | bla bla | + When I run jekyll + Then the _site directory should exist + And the _site/custom/posts/1 directory should exist + And I should see "bla bla" in "_site/custom/posts/1/index.html" + + Scenario: Use per-post ending in .html + Given I have a _posts directory + And I have the following post: + | title | date | permalink | content | + | Some post | 4/14/2013 | /custom/posts/some.html | bla bla | + When I run jekyll + Then the _site directory should exist + And the _site/custom/posts directory should exist + And I should see "bla bla" in "_site/custom/posts/some.html" diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index fd58679d..731d155f 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -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 path).each do |key| + %w(title layout tag tags category categories published author path permalink).each do |key| matter_hash[key] = post[key] if post[key] end matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join.chomp