From 895ab6c45b79a8708068e34305ecd7549e9765ab Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Fri, 29 Nov 2019 19:36:03 +0530 Subject: [PATCH] Memoize #author_hash in SeoTag::AuthorDrop (#342) Merge pull request 342 --- lib/jekyll-seo-tag/author_drop.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/jekyll-seo-tag/author_drop.rb b/lib/jekyll-seo-tag/author_drop.rb index a23c850..b55cff0 100644 --- a/lib/jekyll-seo-tag/author_drop.rb +++ b/lib/jekyll-seo-tag/author_drop.rb @@ -74,12 +74,14 @@ module Jekyll # 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