Class: Jekyll::SeoTag::JSONLDDrop
- Inherits:
-
Drops::Drop
- Object
- Drops::Drop
- Jekyll::SeoTag::JSONLDDrop
- Extended by:
- Forwardable
- Defined in:
- lib/starter_web/_plugins/seo/j1-seo-tags.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(state = nil) ⇒ Object
Returns a JSON-encoded object containing the JSON-LD data.
Constructor Details
#initialize(page_drop) ⇒ JSONLDDrop
page_drop should be an instance of Jekyll::SeoTag::Drop
639 640 641 642 |
# File 'lib/starter_web/_plugins/seo/j1-seo-tags.rb', line 639 def initialize(page_drop) @mutations = {} @page_drop = page_drop end |
Instance Method Details
#author ⇒ Object
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
# File 'lib/starter_web/_plugins/seo/j1-seo-tags.rb', line 650 def return unless page_drop.["name"] = page_drop.["type"] return if && !VALID_AUTHOR_TYPES.include?() hash = { "@type" => || "Person", "name" => page_drop.["name"], } = page_drop.["url"] hash["url"] = if hash end |
#fallback_data ⇒ Object
644 645 646 647 648 |
# File 'lib/starter_web/_plugins/seo/j1-seo-tags.rb', line 644 def fallback_data @fallback_data ||= { "@context" => "https://schema.org", } end |
#image ⇒ Object
667 668 669 670 671 672 673 674 675 |
# File 'lib/starter_web/_plugins/seo/j1-seo-tags.rb', line 667 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
677 678 679 680 681 682 683 684 685 686 687 688 689 |
# File 'lib/starter_web/_plugins/seo/j1-seo-tags.rb', line 677 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(state = nil) ⇒ Object
Returns a JSON-encoded object containing the JSON-LD data. Keys are sorted.
704 705 706 707 708 709 |
# File 'lib/starter_web/_plugins/seo/j1-seo-tags.rb', line 704 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 |