Initialize static files' data hash only if needed (#8188)

Merge pull request 8188
This commit is contained in:
Ashwin Maroli 2020-05-25 21:50:10 +05:30 committed by GitHub
parent bf568cc657
commit c0fde30d4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -4,7 +4,7 @@ module Jekyll
class StaticFile
extend Forwardable
attr_reader :relative_path, :extname, :name, :data
attr_reader :relative_path, :extname, :name
def_delegator :to_liquid, :to_json, :to_json
@ -34,7 +34,6 @@ module Jekyll
@collection = collection
@relative_path = File.join(*[@dir, @name].compact)
@extname = File.extname(@name)
@data = @site.frontmatter_defaults.all(relative_path, type)
end
# rubocop: enable Metrics/ParameterLists
@ -113,6 +112,10 @@ module Jekyll
true
end
def data
@data ||= @site.frontmatter_defaults.all(relative_path, type)
end
def to_liquid
@to_liquid ||= Drops::StaticFileDrop.new(self)
end