From 0920d2b48ab67fadf4ca55f137652ac4f5813485 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Fri, 25 Mar 2016 17:06:26 -0700 Subject: [PATCH] LayoutReader#read: read in Theme layouts if they aren't already registered --- lib/jekyll/readers/layout_reader.rb | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/readers/layout_reader.rb b/lib/jekyll/readers/layout_reader.rb index f0620294..965daf2a 100644 --- a/lib/jekyll/readers/layout_reader.rb +++ b/lib/jekyll/readers/layout_reader.rb @@ -7,8 +7,12 @@ module Jekyll end def read - layout_entries.each do |f| - @layouts[layout_name(f)] = Layout.new(site, layout_directory, f) + layout_entries.each do |layout_file| + @layouts[layout_name(layout_file)] = Layout.new(site, layout_directory, layout_file) + end + + theme_layout_entries.each do |layout_file| + @layouts[layout_name(layout_file)] ||= Layout.new(site, theme_layout_directory, layout_file) end @layouts @@ -18,11 +22,23 @@ module Jekyll @layout_directory ||= (layout_directory_in_cwd || layout_directory_inside_source) end + def theme_layout_directory + @theme_layout_directory ||= site.theme.layout_dir if site.theme + end + private def layout_entries + entries_in layout_directory + end + + def theme_layout_entries + theme_layout_directory ? entries_in(theme_layout_directory) : [] + end + + def entries_in(dir) entries = [] - within(layout_directory) do + within(dir) do entries = EntryFilter.new(site).filter(Dir['**/*.*']) end entries