Initialize static files' data hash only if needed (#8188)
Merge pull request 8188
This commit is contained in:
		
							parent
							
								
									bf568cc657
								
							
						
					
					
						commit
						c0fde30d4b
					
				|  | @ -4,7 +4,7 @@ module Jekyll | ||||||
|   class StaticFile |   class StaticFile | ||||||
|     extend Forwardable |     extend Forwardable | ||||||
| 
 | 
 | ||||||
|     attr_reader :relative_path, :extname, :name, :data |     attr_reader :relative_path, :extname, :name | ||||||
| 
 | 
 | ||||||
|     def_delegator :to_liquid, :to_json, :to_json |     def_delegator :to_liquid, :to_json, :to_json | ||||||
| 
 | 
 | ||||||
|  | @ -34,7 +34,6 @@ module Jekyll | ||||||
|       @collection = collection |       @collection = collection | ||||||
|       @relative_path = File.join(*[@dir, @name].compact) |       @relative_path = File.join(*[@dir, @name].compact) | ||||||
|       @extname = File.extname(@name) |       @extname = File.extname(@name) | ||||||
|       @data = @site.frontmatter_defaults.all(relative_path, type) |  | ||||||
|     end |     end | ||||||
|     # rubocop: enable Metrics/ParameterLists |     # rubocop: enable Metrics/ParameterLists | ||||||
| 
 | 
 | ||||||
|  | @ -113,6 +112,10 @@ module Jekyll | ||||||
|       true |       true | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  |     def data | ||||||
|  |       @data ||= @site.frontmatter_defaults.all(relative_path, type) | ||||||
|  |     end | ||||||
|  | 
 | ||||||
|     def to_liquid |     def to_liquid | ||||||
|       @to_liquid ||= Drops::StaticFileDrop.new(self) |       @to_liquid ||= Drops::StaticFileDrop.new(self) | ||||||
|     end |     end | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue