class Jekyll::SeoTag::JSONLDDrop

def author

def author
  return unless page_drop.author["name"]
  author_type = page_drop.author["type"]
  return if author_type && !VALID_AUTHOR_TYPES.include?(author_type)
  hash = {
    "@type" => author_type || "Person",
    "name"  => page_drop.author["name"],
  }
  author_url = page_drop.author["url"]
  hash["url"] = author_url if author_url
  hash
end

def fallback_data

def fallback_data
  @fallback_data ||= {
    "@context" => "https://schema.org",
  }
end

def image

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

def initialize(page_drop)

page_drop should be an instance of Jekyll::SeoTag::Drop
def initialize(page_drop)
  @mutations = {}
  @page_drop = page_drop
end

def main_entity

def main_entity
  return unless VALID_ENTITY_TYPES.include?(type)
  {
    "@type" => "WebPage",
    "@id"   => page_drop.canonical_url,
  }
end

def publisher

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

def to_json(state = nil)

Keys are sorted.
Returns a JSON-encoded object containing the JSON-LD data.
def to_json(state = nil)
  keys.sort.each_with_object({}) do |(key, _), result|
    v = self[key]
    result[key] = v unless v.nil?
  end.to_json(state)
end