Skip to content

Commit

Permalink
Memoize #author_hash in SeoTag::AuthorDrop (#342)
Browse files Browse the repository at this point in the history
Merge pull request 342
  • Loading branch information
ashmaroli authored and jekyllbot committed Nov 29, 2019
1 parent 3b99176 commit 895ab6c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/jekyll-seo-tag/author_drop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ def site_data_hash
# including site-wide metadata if the author is provided as a string,
# or an empty hash, if the author cannot be resolved
def author_hash
if resolved_author.is_a? Hash
resolved_author
elsif resolved_author.is_a? String
{ "name" => resolved_author }.merge(site_data_hash)
else
{}
@author_hash ||= begin
if resolved_author.is_a? Hash
resolved_author
elsif resolved_author.is_a? String
{ "name" => resolved_author }.merge(site_data_hash)
else
{}
end
end
end

Expand Down

0 comments on commit 895ab6c

Please sign in to comment.