Merge pull request #2799 from kansaichris/add-title-to-collection-permalinks
This commit is contained in:
commit
56cd73eb35
|
@ -45,6 +45,15 @@ module Jekyll
|
|||
File.basename(path, suffix)
|
||||
end
|
||||
|
||||
# The sluggified base filename of the document.
|
||||
#
|
||||
# Returns the base filename of the document in lowercase, with every
|
||||
# sequence of spaces and non-alphanumeric characters replaced with a
|
||||
# hyphen.
|
||||
def slug
|
||||
File.basename(path, ".*").downcase.gsub(/[\W\s]+/, '-')
|
||||
end
|
||||
|
||||
# The extension name of the document.
|
||||
#
|
||||
# Returns the extension name of the document.
|
||||
|
@ -128,7 +137,8 @@ module Jekyll
|
|||
{
|
||||
collection: collection.label,
|
||||
path: cleaned_relative_path,
|
||||
output_ext: Jekyll::Renderer.new(site, self).output_ext
|
||||
output_ext: Jekyll::Renderer.new(site, self).output_ext,
|
||||
name: slug
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -186,6 +186,26 @@ class TestDocument < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
context "a document in a collection with custom permalinks" do
|
||||
setup do
|
||||
@site = Site.new(Jekyll.configuration({
|
||||
"collections" => {
|
||||
"slides" => {
|
||||
"output" => true,
|
||||
"permalink" => "/slides/test/:name"
|
||||
}
|
||||
},
|
||||
"source" => source_dir,
|
||||
"destination" => dest_dir
|
||||
}))
|
||||
@site.process
|
||||
@document = @site.collections["slides"].docs[0]
|
||||
end
|
||||
|
||||
should "produce the right URL" do
|
||||
assert_equal "/slides/test/example-slide-1", @document.url
|
||||
end
|
||||
end
|
||||
|
||||
context "a static file in a collection" do
|
||||
setup do
|
||||
|
|
Loading…
Reference in New Issue