Class: Jekyll::SeoTag::AuthorDrop

Inherits:
Drops::Drop
  • Object
show all
Defined in:
lib/starter_web/_plugins/seo/j1-seo-tags.rb

Overview

A drop representing the current page’s author Author name will be pulled from:

1. The page's `author` key
2. The first author in the page's `authors` key
3. 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`

Instance Method Summary collapse

Constructor Details

#initialize(page: nil, site: nil) ⇒ AuthorDrop

Initialize a new AuthorDrop:

page - The page hash (e.g., Page#to_liquid)
site - The Jekyll::Drops::SiteDrop

Raises:

  • (ArgumentError)


274
275
276
277
278
279
280
# File 'lib/starter_web/_plugins/seo/j1-seo-tags.rb', line 274

def initialize(page: nil, site: nil)
  raise ArgumentError unless page && site

  @mutations = {}
  @page = page
  @site = site
end

Instance Method Details

#nameObject Also known as: to_s

AuthorDrop#to_s should return name, allowing the author drop to safely replace ‘page.author`, if necessary, and remain backwards compatible.



285
286
287
# File 'lib/starter_web/_plugins/seo/j1-seo-tags.rb', line 285

def name
  author_hash["name"]
end

#twitterObject



290
291
292
293
294
295
# File 'lib/starter_web/_plugins/seo/j1-seo-tags.rb', line 290

def twitter
  return @twitter if defined? @twitter

  twitter   = author_hash["twitter"] || author_hash["name"]
  @twitter  = twitter.is_a?(String) ? twitter.sub(%r!^@!, "") : nil
end