fixes problem in issue 64 fix where pages like about.md would be output as about.md/index.html. provides the output extension as a method rather than replacing the ext attribute as part of transform
This commit is contained in:
parent
4fd2b54a7d
commit
f73dac1582
|
@ -0,0 +1 @@
|
|||
default: --format progress
|
|
@ -3,6 +3,7 @@
|
|||
#
|
||||
# Requires
|
||||
# self.site -> Jekyll::Site
|
||||
# self.content
|
||||
# self.content=
|
||||
# self.data=
|
||||
# self.ext=
|
||||
|
@ -31,20 +32,32 @@ module Jekyll
|
|||
self.data ||= {}
|
||||
end
|
||||
|
||||
# Transform the contents based on the file extension.
|
||||
# Transform the contents based on the content type.
|
||||
#
|
||||
# Returns nothing
|
||||
def transform
|
||||
case self.content_type
|
||||
when 'textile'
|
||||
self.ext = ".html"
|
||||
self.content = self.site.textile(self.content)
|
||||
when 'markdown'
|
||||
self.ext = ".html"
|
||||
self.content = self.site.markdown(self.content)
|
||||
end
|
||||
end
|
||||
|
||||
# Determine the extension depending on content_type
|
||||
#
|
||||
# Returns the extensions for the output file
|
||||
def output_ext
|
||||
case self.content_type
|
||||
when 'textile'
|
||||
".html"
|
||||
when 'markdown'
|
||||
".html"
|
||||
else
|
||||
self.ext
|
||||
end
|
||||
end
|
||||
|
||||
# Determine which formatting engine to use based on this convertible's
|
||||
# extension
|
||||
#
|
||||
|
|
|
@ -43,10 +43,10 @@ module Jekyll
|
|||
end
|
||||
|
||||
def template
|
||||
if self.site.permalink_style == :pretty && !index?
|
||||
"/:name/"
|
||||
if self.site.permalink_style == :pretty && !index? && html?
|
||||
"/:basename/"
|
||||
else
|
||||
"/:name.html"
|
||||
"/:basename:output_ext"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -57,7 +57,12 @@ module Jekyll
|
|||
def url
|
||||
return permalink if permalink
|
||||
|
||||
@url ||= (ext == '.html') ? template.gsub(':name', basename) : "/#{name}"
|
||||
@url ||= {
|
||||
"basename" => self.basename,
|
||||
"output_ext" => self.output_ext,
|
||||
}.inject(template) { |result, token|
|
||||
result.gsub(/:#{token.first}/, token.last)
|
||||
}.gsub(/\/\//, "/")
|
||||
end
|
||||
|
||||
# Extract information from the page filename
|
||||
|
@ -91,7 +96,7 @@ module Jekyll
|
|||
|
||||
# The url needs to be unescaped in order to preserve the correct filename
|
||||
path = File.join(dest, CGI.unescape(self.url))
|
||||
if self.ext == '.html' && self.url[/\.html$/].nil?
|
||||
if self.url =~ /\/$/
|
||||
FileUtils.mkdir_p(path)
|
||||
path = File.join(path, "index.html")
|
||||
end
|
||||
|
@ -107,6 +112,10 @@ module Jekyll
|
|||
|
||||
private
|
||||
|
||||
def html?
|
||||
output_ext == '.html'
|
||||
end
|
||||
|
||||
def index?
|
||||
basename == 'index'
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue