Fix pretty url style paths.

Ignore the basename if the page is an index page, preserve it if it's just an
html page and use the full path in every other case.
This commit is contained in:
Fotos Georgiadis 2013-02-28 03:49:39 +02:00
parent 4090500c5a
commit 441eddf1ca
2 changed files with 15 additions and 4 deletions

View File

@ -45,8 +45,14 @@ module Jekyll
#
# Returns the template String.
def template
if self.site.permalink_style == :pretty && !index? && html?
"/:path/:basename/"
if self.site.permalink_style == :pretty
if index? && html?
"/:path/"
elsif html?
"/:path/:basename/"
else
"/:path/:basename:output_ext"
end
else
"/:path/:basename:output_ext"
end

View File

@ -64,8 +64,13 @@ class TestPage < Test::Unit::TestCase
context "in a directory hierarchy" do
should "create url based on filename" do
@page = setup_page('/contacts', 'bar.html')
assert_equal "/contacts/bar/", @page.url
end
should "create index url based on filename" do
@page = setup_page('/contacts', 'index.html')
assert_equal "/contacts/index.html", @page.url
assert_equal "/contacts/", @page.url
end
should "return dir correctly" do
@ -75,7 +80,7 @@ class TestPage < Test::Unit::TestCase
should "return dir correctly for index page" do
@page = setup_page('/contacts', 'index.html')
assert_equal '/contacts', @page.dir
assert_equal '/contacts/', @page.dir
end
end
end