class Jekyll::SeoTag::AuthorDrop
A drop representing the current page's author
Author name will be pulled from:
-
The page's `author` key
-
The first author in the page's `authors` key
-
The `author` key in the site config
If the result from the name search is a string, we'll also check for additional author metadata in `site.data.authors`
Attributes
Public Class Methods
Initialize a new AuthorDrop
page - The page hash (e.g., Page#to_liquid) site - The Jekyll::Drops::SiteDrop
# File lib/jekyll-seo-tag/author_drop.rb, line 20 def initialize(page: nil, site: nil) raise ArgumentError unless page && site @mutations = {} @page = page @site = site end
Public Instance Methods
#to_s should return name, allowing the author drop to safely replace `page.author`, if necessary, and remain backwards compatible
# File lib/jekyll-seo-tag/author_drop.rb, line 30 def name author_hash["name"] end
# File lib/jekyll-seo-tag/author_drop.rb, line 35 def twitter return @twitter if defined? @twitter twitter = author_hash["twitter"] || author_hash["name"] @twitter = twitter.is_a?(String) ? twitter.sub(%r!^@!, "") : nil end
Private Instance Methods
Since #author_hash is aliased to #fallback_data, any values in the hash will be exposed via the drop, allowing support for arbitrary metadata
If #resolved_author is a string, attempts to find coresponding author metadata in `site.data.authors`
Returns a hash representing additional metadata or an empty hash
# File lib/jekyll-seo-tag/author_drop.rb, line 63 def site_data_hash @site_data_hash ||= begin return {} unless resolved_author.is_a?(String) return {} unless site.data["authors"].is_a?(Hash) author_hash = site.data["authors"][resolved_author] author_hash.is_a?(Hash) ? author_hash : {} end end