Clean up frontmatter a bit
This commit is contained in:
parent
38b3d5155d
commit
f611a7185b
|
@ -38,7 +38,7 @@ module Middleman::CoreExtensions
|
||||||
::Middleman::Sitemap::Resource.send :include, ResourceInstanceMethods
|
::Middleman::Sitemap::Resource.send :include, ResourceInstanceMethods
|
||||||
|
|
||||||
app.sitemap.provides_metadata do |path|
|
app.sitemap.provides_metadata do |path|
|
||||||
fmdata = data(path).first || {}
|
fmdata = data(path).first
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
[:layout, :layout_engine].each do |opt|
|
[:layout, :layout_engine].each do |opt|
|
||||||
|
@ -69,19 +69,15 @@ module Middleman::CoreExtensions
|
||||||
# This page's frontmatter
|
# This page's frontmatter
|
||||||
# @return [Hash]
|
# @return [Hash]
|
||||||
def data
|
def data
|
||||||
@enhanced_data ||= {}
|
@enhanced_data ||= ::Middleman::Util.recursively_enhance(raw_data).freeze
|
||||||
@enhanced_data[raw_data] ||= begin
|
|
||||||
::Middleman::Util.recursively_enhance(raw_data).freeze
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Override Resource#content_type to take into account frontmatter
|
# Override Resource#content_type to take into account frontmatter
|
||||||
def content_type
|
def content_type
|
||||||
# Allow setting content type in frontmatter too
|
# Allow setting content type in frontmatter too
|
||||||
fm_type = raw_data[:content_type]
|
raw_data.fetch :content_type do
|
||||||
return fm_type if fm_type
|
super
|
||||||
|
end
|
||||||
super
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -97,18 +93,14 @@ module Middleman::CoreExtensions
|
||||||
def data(path)
|
def data(path)
|
||||||
p = normalize_path(path)
|
p = normalize_path(path)
|
||||||
@cache[p] ||= begin
|
@cache[p] ||= begin
|
||||||
file_data, content = frontmatter_and_content(p)
|
data, content = frontmatter_and_content(p)
|
||||||
|
|
||||||
if app.files.exists?("#{path}.frontmatter")
|
if app.files.exists?("#{path}.frontmatter")
|
||||||
external_data, _ = frontmatter_and_content("#{p}.frontmatter")
|
external_data, _ = frontmatter_and_content("#{p}.frontmatter")
|
||||||
|
data = external_data.deep_merge(data)
|
||||||
[
|
|
||||||
external_data.deep_merge(file_data),
|
|
||||||
content
|
|
||||||
]
|
|
||||||
else
|
|
||||||
[file_data, content]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
[data, content]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue