the index page should always have index.html permalink no matter what
This commit is contained in:
parent
ee0167d706
commit
49c39f43a1
|
@ -23,6 +23,15 @@ Feature: Fancy permalinks
|
|||
Then the _site directory should exist
|
||||
And I should see "Totally wordpress." in "_site/2009/03/27/pretty-permalink-schema/index.html"
|
||||
|
||||
Scenario: Use pretty permalink schema for pages
|
||||
Given I have an "index.html" page that contains "Totally index"
|
||||
And I have an "awesome.html" page that contains "Totally awesome"
|
||||
And I have a configuration file with "permalink" set to "pretty"
|
||||
When I run jekyll
|
||||
Then the _site directory should exist
|
||||
And I should see "Totally index" in "_site/index.html"
|
||||
And I should see "Totally awesome" in "_site/awesome/index.html"
|
||||
|
||||
Scenario: Use custom permalink schema with prefix
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
|
|
|
@ -4,7 +4,7 @@ module Jekyll
|
|||
include Convertible
|
||||
|
||||
attr_accessor :site
|
||||
attr_accessor :name, :ext
|
||||
attr_accessor :name, :ext, :basename
|
||||
attr_accessor :data, :content, :output
|
||||
|
||||
# Initialize a new Page.
|
||||
|
@ -24,7 +24,6 @@ module Jekyll
|
|||
|
||||
self.process(name)
|
||||
self.read_yaml(File.join(base, dir), name)
|
||||
#self.transform
|
||||
end
|
||||
|
||||
# The generated directory into which the page will be placed
|
||||
|
@ -46,7 +45,7 @@ module Jekyll
|
|||
end
|
||||
|
||||
def template
|
||||
if self.site.permalink_style == :pretty
|
||||
if self.site.permalink_style == :pretty && !index?
|
||||
"/:name/"
|
||||
else
|
||||
"/:name.html"
|
||||
|
@ -60,7 +59,7 @@ module Jekyll
|
|||
def url
|
||||
return permalink if permalink
|
||||
|
||||
@url ||= template.gsub(':name', name.split('.')[0..-2].first)
|
||||
@url ||= template.gsub(':name', basename)
|
||||
end
|
||||
|
||||
# Extract information from the page filename
|
||||
|
@ -69,6 +68,7 @@ module Jekyll
|
|||
# Returns nothing
|
||||
def process(name)
|
||||
self.ext = File.extname(name)
|
||||
self.basename = name.split('.')[0..-2].first
|
||||
end
|
||||
|
||||
# Add any necessary layouts to this post
|
||||
|
@ -102,6 +102,13 @@ module Jekyll
|
|||
f.write(self.output)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def index?
|
||||
basename == 'index'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -24,11 +24,19 @@ class TestPage < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
context "with pretty url style" do
|
||||
should "return dir correctly" do
|
||||
setup do
|
||||
@site.permalink_style = :pretty
|
||||
end
|
||||
|
||||
should "return dir correctly" do
|
||||
@page = setup_page('contacts.html')
|
||||
assert_equal '/contacts/', @page.dir
|
||||
end
|
||||
|
||||
should "return dir correctly for index page" do
|
||||
@page = setup_page('index.html')
|
||||
assert_equal '/', @page.dir
|
||||
end
|
||||
end
|
||||
|
||||
context "with any other url style" do
|
||||
|
|
Loading…
Reference in New Issue