Set @path and @base_dir on the Layout per whether it's in the theme
This commit is contained in:
parent
d5dd423bfd
commit
2b73696d03
|
@ -39,7 +39,7 @@ module Jekyll
|
||||||
filename = File.join(base, name)
|
filename = File.join(base, name)
|
||||||
|
|
||||||
begin
|
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))
|
Utils.merged_file_read_opts(site, opts))
|
||||||
if content =~ Document::YAML_FRONT_MATTER_REGEXP
|
if content =~ Document::YAML_FRONT_MATTER_REGEXP
|
||||||
self.content = $POSTMATCH
|
self.content = $POSTMATCH
|
||||||
|
|
|
@ -29,7 +29,14 @@ module Jekyll
|
||||||
@site = site
|
@site = site
|
||||||
@base = base
|
@base = base
|
||||||
@name = name
|
@name = 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)
|
@path = site.in_source_dir(base, name)
|
||||||
|
end
|
||||||
|
|
||||||
self.data = {}
|
self.data = {}
|
||||||
|
|
||||||
|
@ -51,7 +58,7 @@ module Jekyll
|
||||||
# Returns a String path which represents the relative path
|
# Returns a String path which represents the relative path
|
||||||
# from the site source to this layout
|
# from the site source to this layout
|
||||||
def relative_path
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,6 +40,7 @@ module Jekyll
|
||||||
@base = base
|
@base = base
|
||||||
@dir = dir
|
@dir = dir
|
||||||
@name = name
|
@name = name
|
||||||
|
@path = site.in_source_dir(base, dir, name)
|
||||||
|
|
||||||
process(name)
|
process(name)
|
||||||
read_yaml(File.join(base, dir), name)
|
read_yaml(File.join(base, dir), name)
|
||||||
|
|
|
@ -373,6 +373,19 @@ module Jekyll
|
||||||
end
|
end
|
||||||
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.
|
# Public: Prefix a given path with the destination directory.
|
||||||
#
|
#
|
||||||
# paths - (optional) path elements to a file or directory within the
|
# paths - (optional) path elements to a file or directory within the
|
||||||
|
|
Loading…
Reference in New Issue