Class: Jekyll::SeoTag::JSONLDDrop
- Inherits:
-
Drops::Drop
- Object
- Drops::Drop
- Jekyll::SeoTag::JSONLDDrop
- Extended by:
- Forwardable
- Defined in:
- lib/jekyll-seo-tag/json_ld_drop.rb
Instance Method Summary collapse
- #author ⇒ Object
- #fallback_data ⇒ Object
- #image ⇒ Object
-
#initialize(page_drop) ⇒ JSONLDDrop
constructor
page_drop should be an instance of Jekyll::SeoTag::Drop.
- #publisher ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(page_drop) ⇒ JSONLDDrop
page_drop should be an instance of Jekyll::SeoTag::Drop
24 25 26 27 |
# File 'lib/jekyll-seo-tag/json_ld_drop.rb', line 24 def initialize(page_drop) @mutations = {} @page_drop = page_drop end |
Instance Method Details
#author ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/jekyll-seo-tag/json_ld_drop.rb', line 35 def return unless page_drop.["name"] { "@type" => "Person", "name" => page_drop.["name"], } end |
#fallback_data ⇒ Object
29 30 31 32 33 |
# File 'lib/jekyll-seo-tag/json_ld_drop.rb', line 29 def fallback_data { "@context" => "https://schema.org", } end |
#image ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/jekyll-seo-tag/json_ld_drop.rb', line 44 def image return unless page_drop.image return page_drop.image.path if page_drop.image.keys.length == 1 hash = page_drop.image.to_h hash["url"] = hash.delete("path") hash["@type"] = "imageObject" hash end |
#publisher ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/jekyll-seo-tag/json_ld_drop.rb', line 54 def publisher return unless logo output = { "@type" => "Organization", "logo" => { "@type" => "ImageObject", "url" => logo, }, } output["name"] = page_drop..name if page_drop..name output end |
#to_json ⇒ Object
79 80 81 |
# File 'lib/jekyll-seo-tag/json_ld_drop.rb', line 79 def to_json to_h.reject { |_k, v| v.nil? }.to_json end |