Allow frontmatter to be parsed on templates outside the project root
This commit is contained in:
parent
8d5dd8e8ce
commit
c9290c6b11
|
@ -1,3 +1,5 @@
|
||||||
|
require 'pathname'
|
||||||
|
|
||||||
# Extensions namespace
|
# Extensions namespace
|
||||||
module Middleman::CoreExtensions
|
module Middleman::CoreExtensions
|
||||||
|
|
||||||
|
@ -128,7 +130,12 @@ module Middleman::CoreExtensions
|
||||||
# @param [String] path
|
# @param [String] path
|
||||||
# @return [Array<Thor::CoreExt::HashWithIndifferentAccess, String>]
|
# @return [Array<Thor::CoreExt::HashWithIndifferentAccess, String>]
|
||||||
def frontmatter_and_content(path)
|
def frontmatter_and_content(path)
|
||||||
full_path = File.expand_path(File.join(@app.source_dir, path))
|
full_path = if Pathname(path).relative?
|
||||||
|
File.join(@app.source_dir, path)
|
||||||
|
else
|
||||||
|
path
|
||||||
|
end
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
content = nil
|
content = nil
|
||||||
|
|
||||||
|
@ -156,7 +163,7 @@ module Middleman::CoreExtensions
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize_path(path)
|
def normalize_path(path)
|
||||||
path.sub(@app.source_dir, "").sub(/^\//, "")
|
path.sub(%r{^#{@app.source_dir}\/}, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Update the main sitemap resource list
|
# Update the main sitemap resource list
|
||||||
|
|
Loading…
Reference in a new issue