Module: Jekyll::SeoTag::JSONLD

Included in:
Drop
Defined in:
lib/jekyll-seo-tag/json_ld.rb

Constant Summary collapse

METHODS_KEYS =

A hash of instance methods => key in resulting JSON-LD hash

{
  :json_context   => "@context",
  :type           => "@type",
  :name           => "name",
  :page_title     => "headline",
  :json_author    => "author",
  :json_image     => "image",
  :date_published => "datePublished",
  :date_modified  => "dateModified",
  :description    => "description",
  :publisher      => "publisher",
  :main_entity    => "mainEntityOfPage",
  :links          => "sameAs",
  :canonical_url  => "url",
}.freeze

Instance Method Summary collapse

Instance Method Details

#json_ldObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/jekyll-seo-tag/json_ld.rb', line 22

def json_ld
  @json_ld ||= begin
    output = {}
    METHODS_KEYS.each do |method, key|
      value = send(method)
      output[key] = value unless value.nil?
    end
    output
  end
end