class Jekyll::SeoTag::AuthorDrop
for additional author metadata in ‘site.data.authors`
If the result from the name search is a string, we’ll also check
3. The ‘author` key in the site config
2. The first author in the page’s ‘authors` key
1. The page’s ‘author` key
Author name will be pulled from:
A drop representing the current page’s author
def author_hash
including site-wide metadata if the author is provided as a string,
Returns the normalized author hash representing the page author,
def author_hash @author_hash ||= begin case resolved_author when Hash resolved_author when String { "name" => resolved_author }.merge!(site_data_hash) else {} end end end
def initialize(page: nil, site: nil)
page - The page hash (e.g., Page#to_liquid)
Initialize a new AuthorDrop
def initialize(page: nil, site: nil) raise ArgumentError unless page && site @mutations = {} @page = page @site = site end
def name
AuthorDrop#to_s should return name, allowing the author drop to safely
def name author_hash["name"] end
def resolved_author
Finds the page author in the page.author, page.authors, or site.author
def resolved_author return @resolved_author if defined? @resolved_author sources = [page["author"]] sources << page["authors"].first if page["authors"].is_a?(Array) sources << site["author"] @resolved_author = sources.find { |s| !s.to_s.empty? } end
def site_data_hash
metadata in `site.data.authors`
If resolved_author is a string, attempts to find coresponding author
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
def twitter
def twitter return @twitter if defined? @twitter twitter = author_hash["twitter"] || author_hash["name"] @twitter = twitter.is_a?(String) ? twitter.sub(%r!^@!, "") : nil end