diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index 0a2e3106..a473b183 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -39,7 +39,7 @@ module Jekyll filename = File.join(base, name) begin - self.content = File.read(site.in_source_dir(base, name), + self.content = File.read(@path || site.in_source_dir(base, name), Utils.merged_file_read_opts(site, opts)) if content =~ Document::YAML_FRONT_MATTER_REGEXP self.content = $POSTMATCH diff --git a/lib/jekyll/layout.rb b/lib/jekyll/layout.rb index aed6afe1..72005277 100644 --- a/lib/jekyll/layout.rb +++ b/lib/jekyll/layout.rb @@ -29,7 +29,14 @@ module Jekyll @site = site @base = base @name = name - @path = site.in_source_dir(base, name) + + if site.theme && site.theme.layouts_path.eql?(base) + @base_dir = site.theme.root + @path = site.in_theme_dir(base, name) + else + @base_dir = site.source + @path = site.in_source_dir(base, name) + end self.data = {} @@ -51,7 +58,7 @@ module Jekyll # Returns a String path which represents the relative path # from the site source to this layout def relative_path - @relative_path ||= Pathname.new(path).relative_path_from(Pathname.new(site.source)).to_s + @relative_path ||= Pathname.new(path).relative_path_from(Pathname.new(@base_dir)).to_s end end end diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 6c402ee3..2bdcdf6f 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -40,6 +40,7 @@ module Jekyll @base = base @dir = dir @name = name + @path = site.in_source_dir(base, dir, name) process(name) read_yaml(File.join(base, dir), name) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 9ceda0a0..9afdbde3 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -373,6 +373,19 @@ module Jekyll end end + # Public: Prefix a given path with the theme directory. + # + # paths - (optional) path elements to a file or directory within the + # theme directory + # + # Returns a path which is prefixed with the theme root directory. + def in_theme_dir(*paths) + return nil unless theme + paths.reduce(theme.root) do |base, path| + Jekyll.sanitized_path(base, path) + end + end + # Public: Prefix a given path with the destination directory. # # paths - (optional) path elements to a file or directory within the