Improved permalinks for pages and collections

This updates the default permalink style for pages and collections to
match the site-wide 'permalink' setting.  If the permalink setting
contains a trailing slash, either explicitly or by being set to
':pretty', then pages and collections permalinks will contain trailing
slashes by default as well.  Similarly, if the permalink setting
contains a trailing ':output_ext', so will pages and collections.  If
the permalink setting contains neither a trailing slash or extension,
neither will pages or collections.

This impacts only the default permalink structure for pages and
collections.  Permalinks set in the frontmatter of an individual page
take precedence, as does the permalink setting for a specific
collection.

Fixes #2691
This commit is contained in:
Will Norris
2015-02-28 22:23:08 -08:00
parent 5e9b7343bf
commit 0d1586a5c4
6 changed files with 140 additions and 12 deletions

View File

@@ -219,7 +219,31 @@ class TestDocument < JekyllUnitTest
assert_equal "/slides/test/example-slide-1", @document.url
end
should "produce the right destination" do
should "produce the right destination file" do
assert_equal @dest_file, @document.destination(dest_dir)
end
end
context "a document in a collection with pretty permalink style" do
setup do
@site = fixture_site({
"collections" => {
"slides" => {
"output" => true,
}
},
})
@site.permalink_style = :pretty
@site.process
@document = @site.collections["slides"].docs[0]
@dest_file = dest_dir("slides/example-slide-1/index.html")
end
should "produce the right URL" do
assert_equal "/slides/example-slide-1/", @document.url
end
should "produce the right destination file" do
assert_equal @dest_file, @document.destination(dest_dir)
end
end