Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/jekyll-archives/archive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ def initialize(site, title, type, posts)
#
# Returns the template String.
def template
@config.dig("permalinks", type)
permalinks = @config["permalinks"]
permalinks[type] if permalinks.is_a?(Hash)
end

# The layout to use for rendering
#
# Returns the layout as a String
def layout
@config.dig("layouts", type) || @config["layout"]
layouts = @config["layouts"]
(layouts[type] if layouts.is_a?(Hash)) || @config["layout"]
end

# Returns a hash of URL placeholder names (as symbols) mapping to the
Expand Down
19 changes: 19 additions & 0 deletions test/test_jekyll_archives.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,25 @@ class TestJekyllArchives < Minitest::Test
end
end


context "the jekyll-archives plugin with malformed layouts config" do
setup do
@site = fixture_site(
"jekyll-archives" => {
"enabled" => true,
"layouts" => "archive-too",
}
)
end

should "fall back to the default layout instead of crashing" do
@site.process

assert_equal "Test", read_file("/2014/index.html")
assert_equal "Test", read_file("/tag/test-tag/index.html")
end
end

context "the archives" do
setup do
@site = fixture_site("jekyll-archives" => {
Expand Down