class Jekyll::SeoTag::JSONLDDrop
Attributes
page_drop[R]
Public Class Methods
new(page_drop)
click to toggle source
#page_drop should be an instance of Jekyll::SeoTag::Drop
# File lib/jekyll-seo-tag/json_ld_drop.rb, line 24 def initialize(page_drop) @mutations = {} @page_drop = page_drop end
Public Instance Methods
fallback_data()
click to toggle source
# File lib/jekyll-seo-tag/json_ld_drop.rb, line 29 def fallback_data { "@context" => "https://schema.org", } end
image()
click to toggle source
# 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()
click to toggle source
# 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.author.name if page_drop.author.name output end
to_json()
click to toggle source
# File lib/jekyll-seo-tag/json_ld_drop.rb, line 79 def to_json to_h.reject { |_k, v| v.nil? }.to_json end
Private Instance Methods
main_entity()
click to toggle source
# File lib/jekyll-seo-tag/json_ld_drop.rb, line 68 def main_entity return unless %w(BlogPosting CreativeWork).include?(type) { "@type" => "WebPage", "@id" => page_drop.canonical_url, } end
Also aliased as: mainEntityOfPage