Skip to content

Commit 5636656

Browse files
committed
Add method to avoid changing public layout_reader method signature
1 parent a76eb93 commit 5636656

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/jekyll/readers/layout_reader.rb

+11-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def read
1818
site.theme_list.each do |theme|
1919
theme_layout_entries(theme).each do |layout_file|
2020
@layouts[layout_name(layout_file)] ||= \
21-
Layout.new(site, theme_layout_directory(theme), layout_file, theme)
21+
Layout.new(site, theme_layout_directory_for_theme(theme), layout_file, theme)
2222
end
2323
end
2424

@@ -29,7 +29,14 @@ def layout_directory
2929
@layout_directory ||= site.in_source_dir(site.config["layouts_dir"])
3030
end
3131

32-
def theme_layout_directory(theme)
32+
# NOTE: Returns only the site's theme layout path. However, this does not
33+
# account for theme inheritance. Use `theme_layout_directory_for_theme`
34+
# instead.
35+
def theme_layout_directory
36+
@theme_layout_directory ||= site.theme.layouts_path if site.theme
37+
end
38+
39+
def theme_layout_directory_for_theme(theme)
3340
return nil unless theme
3441

3542
theme.layouts_path
@@ -42,8 +49,8 @@ def layout_entries
4249
end
4350

4451
def theme_layout_entries(theme)
45-
if theme_layout_directory(theme)
46-
entries_in(theme_layout_directory(theme))
52+
if theme_layout_directory_for_theme(theme)
53+
entries_in(theme_layout_directory_for_theme(theme))
4754
else
4855
[]
4956
end

0 commit comments

Comments
 (0)