Skip to content

Commit

Permalink
Initialize static files' data hash only if needed (#8188)
Browse files Browse the repository at this point in the history
Merge pull request 8188
  • Loading branch information
ashmaroli committed May 25, 2020
1 parent bf568cc commit c0fde30
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/jekyll/static_file.rb
Expand Up @@ -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

Expand Down Expand Up @@ -34,7 +34,6 @@ def initialize(site, base, dir, name, collection = nil)
@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

Expand Down Expand Up @@ -113,6 +112,10 @@ def write(dest)
true
end

def data
@data ||= @site.frontmatter_defaults.all(relative_path, type)
end

def to_liquid
@to_liquid ||= Drops::StaticFileDrop.new(self)
end
Expand Down

0 comments on commit c0fde30

Please sign in to comment.