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,11 +45,17 @@ module Jekyll
# #
# Returns the template String. # Returns the template String.
def template def template
if self.site.permalink_style == :pretty && !index? && html? if self.site.permalink_style == :pretty
if index? && html?
"/:path/"
elsif html?
"/:path/:basename/" "/:path/:basename/"
else else
"/:path/:basename:output_ext" "/:path/:basename:output_ext"
end end
else
"/:path/:basename:output_ext"
end
end end
# The generated relative url of this page. e.g. /about.html. # The generated relative url of this page. e.g. /about.html.

View File

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