From 4a09d202bb306ec955ac67b5f7499a04e369ede6 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Mon, 8 Apr 2019 12:14:42 +0530 Subject: [PATCH] Memoize #author_hash in SeoTag::AuthorDrop --- 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 a23c8505..b55cff03 100644 --- a/lib/jekyll-seo-tag/author_drop.rb +++ b/lib/jekyll-seo-tag/author_drop.rb @@ -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