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