From 891d6218990e453384d27aea428617f9f441ea0f Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Wed, 23 Aug 2017 11:07:52 -0400 Subject: [PATCH 01/13] move author logic to its own drop --- Gemfile | 2 - lib/jekyll-seo-tag.rb | 3 +- lib/jekyll-seo-tag/author_drop.rb | 88 +++++++++++++++++++++++++++++++ lib/jekyll-seo-tag/drop.rb | 53 +------------------ spec/jekyll_seo_tag/drop_spec.rb | 18 +++++-- 5 files changed, 106 insertions(+), 58 deletions(-) create mode 100644 lib/jekyll-seo-tag/author_drop.rb diff --git a/Gemfile b/Gemfile index ab00218..2ee12d7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,4 @@ source "https://rubygems.org" -require "json" -require "open-uri" gemspec diff --git a/lib/jekyll-seo-tag.rb b/lib/jekyll-seo-tag.rb index 6d3e4b8..44ec08b 100644 --- a/lib/jekyll-seo-tag.rb +++ b/lib/jekyll-seo-tag.rb @@ -3,7 +3,8 @@ require "jekyll-seo-tag/version" module Jekyll class SeoTag < Liquid::Tag - autoload :JSONLD, "jekyll-seo-tag/json_ld" + autoload :JSONLD, "jekyll-seo-tag/json_ld" + autoload :AuthorDrop, "jekyll-seo-tag/author_drop" autoload :Drop, "jekyll-seo-tag/drop" autoload :Filters, "jekyll-seo-tag/filters" diff --git a/lib/jekyll-seo-tag/author_drop.rb b/lib/jekyll-seo-tag/author_drop.rb new file mode 100644 index 0000000..7827307 --- /dev/null +++ b/lib/jekyll-seo-tag/author_drop.rb @@ -0,0 +1,88 @@ +module Jekyll + class SeoTag + class AuthorDrop < Jekyll::Drops::Drop + # A drop representing the current page's author + # + # Author name will be pulled from: + # + # 1. The page's `author` key + # 2. The first author in the page's `authors` key + # 3. The `author` key in the site config + # + # If the result from the name search is a string, we'll also check + # for additional author metadata in `site.data.authors` + def initialize(page: nil, site: nil) + raise ArugementError unless page && site + @mutations = {} + @page = page + @site = site + end + + # Public methods to delegate to keys of the author hash + # Ensures keys will be present when `to_h` is called, even with nil values + DELEGATED_METHODS = %i[name picture].freeze + + DELEGATED_METHODS.each do |meth| + define_method meth do + author_hash[meth.to_s] + end + end + + # AuthorDrop#to_s should return name, allowing the author drop to safely + # replace `page.author`, if necessary, and remain backwards compatible + alias_method :to_s, :name + + def twitter + return @twitter if defined? @twitter + twitter = author_hash["twitter"] || author_hash["name"] + @twitter = twitter.is_a?(String) ? twitter.sub(%r!^@!, "") : nil + end + + private + + attr_reader :page + attr_reader :site + + # Finds the page author in the page.author, page.authors, or site.author + # + # Returns a string or hash representing the author + def resolved_author + return @resolved_author if defined? @resolved_author + sources = [page["author"]] + sources << page["authors"].first if page["authors"].is_a?(Array) + sources << site["author"] + @resolved_author = sources.find { |s| !s.to_s.empty? } + end + + # If resolved_author is a string, attempts to find coresponding author + # metadata in `site.data.authors` + # + # Returns a hash representing additional metadata or an empty hash + def site_data_hash + @site_data_hash ||= begin + return {} unless resolved_author.is_a?(String) + return {} unless site.data["authors"].is_a?(Hash) + author_hash = site.data["authors"][resolved_author] + author_hash.is_a?(Hash) ? author_hash : {} + end + end + + # Returns the normalized author hash representing the page author, + # including site-wide metadata if the author is provided as a string, + # or an empty hash, if the author cannot be resolved + def author_hash + if resolved_author.is_a? Hash + resolved_author + elsif resolved_author.is_a? String + { "name" => resolved_author }.merge(site_data_hash) + else + {} + end + end + + # Since author_hash is aliased to fallback_data, any values in the hash + # will be exposed via the drop, allowing support for arbitrary metadata + alias_method :fallback_data, :author_hash + end + end +end diff --git a/lib/jekyll-seo-tag/drop.rb b/lib/jekyll-seo-tag/drop.rb index 1973c65..d6a1649 100644 --- a/lib/jekyll-seo-tag/drop.rb +++ b/lib/jekyll-seo-tag/drop.rb @@ -72,29 +72,9 @@ module Jekyll end end - # Returns a nil or a hash representing the author - # Author name will be pulled from: - # - # 1. The `author` key, if the key is a string - # 2. The first author in the `authors` key - # 3. The `author` key in the site config - # - # If the result from the name search is a string, we'll also check - # to see if the author exists in `site.data.authors` + # A drop representing the page author def author - @author ||= begin - return if author_string_or_hash.to_s.empty? - - author = if author_string_or_hash.is_a?(String) - author_hash(author_string_or_hash) - else - author_string_or_hash - end - - author["twitter"] ||= author["name"] - author["twitter"].delete! "@" if author["twitter"] - author.to_liquid - end + @author ||= AuthorDrop.new(:page => page, :site => site) end def date_modified @@ -231,35 +211,6 @@ module Jekyll string unless string.empty? end - def author_string_or_hash - @author_string_or_hash ||= begin - author = page["author"] - author = page["authors"][0] if author.to_s.empty? && page["authors"] - author = site["author"] if author.to_s.empty? - author - end - end - - # Given a string representing the current document's author, return - # a normalized hash representing that author. Will try to pull from - # site.authors if present and in the proper format. - def author_hash(author_string) - site_author_hash(author_string) || { "name" => author_string } - end - - # Given a string representing the current document's author, attempt - # to retrieve additional metadata from site.data.authors, if present - # - # Returns the author hash - def site_author_hash(author_string) - return unless site.data["authors"] && site.data["authors"].is_a?(Hash) - author_hash = site.data["authors"][author_string] - return unless author_hash.is_a?(Hash) - author_hash["name"] ||= author_string - author_hash["twitter"] ||= author_string - author_hash - end - def seo_name @seo_name ||= format_string(page_seo["name"]) if page_seo["name"] end diff --git a/spec/jekyll_seo_tag/drop_spec.rb b/spec/jekyll_seo_tag/drop_spec.rb index fe54161..27fd406 100644 --- a/spec/jekyll_seo_tag/drop_spec.rb +++ b/spec/jekyll_seo_tag/drop_spec.rb @@ -223,6 +223,16 @@ RSpec.describe Jekyll::SeoTag::Drop do end context "author" do + let(:name) { "foo" } + let(:twitter) { "foo" } + let(:picture) { nil } + let(:expected_hash) do + { + "name" => name, + "twitter" => twitter, + "picture" => picture, + } + end let(:data) { {} } let(:config) { { "author" => "site_author" } } let(:site) do @@ -236,7 +246,7 @@ RSpec.describe Jekyll::SeoTag::Drop do let(:page_meta) { { "author" => "foo" } } it "doesn't error" do - expect(subject.author).to eql({ "name" => "foo", "twitter" => "foo" }) + expect(subject.author.to_h).to eql(expected_hash) end end @@ -245,7 +255,7 @@ RSpec.describe Jekyll::SeoTag::Drop do let(:page_meta) { { "author" => "foo" } } it "doesn't error" do - expect(subject.author).to eql({ "name" => "foo", "twitter" => "foo" }) + expect(subject.author.to_h).to eql(expected_hash) end end @@ -279,8 +289,8 @@ RSpec.describe Jekyll::SeoTag::Drop do "#{author_type}_author".sub("nil_", "site_").sub("empty_string_", "site_") end - it "returns a hash" do - expect(subject.author).to be_a(Hash) + it "returns a Drop" do + expect(subject.author).to be_a(Jekyll::SeoTag::AuthorDrop) end it "returns the name" do From 2e90fc7238be8c500da34ea2176a214734f4a54b Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Wed, 23 Aug 2017 11:32:36 -0400 Subject: [PATCH 02/13] move author drop tests to their own spec --- lib/jekyll-seo-tag/author_drop.rb | 37 +++--- spec/jekyll_seo_tag/author_drop_spec.rb | 162 ++++++++++++++++++++++++ spec/jekyll_seo_tag/drop_spec.rb | 140 ++------------------ 3 files changed, 188 insertions(+), 151 deletions(-) create mode 100644 spec/jekyll_seo_tag/author_drop_spec.rb diff --git a/lib/jekyll-seo-tag/author_drop.rb b/lib/jekyll-seo-tag/author_drop.rb index 7827307..6992539 100644 --- a/lib/jekyll-seo-tag/author_drop.rb +++ b/lib/jekyll-seo-tag/author_drop.rb @@ -1,35 +1,32 @@ module Jekyll class SeoTag + # A drop representing the current page's author + # + # Author name will be pulled from: + # + # 1. The page's `author` key + # 2. The first author in the page's `authors` key + # 3. The `author` key in the site config + # + # If the result from the name search is a string, we'll also check + # for additional author metadata in `site.data.authors` class AuthorDrop < Jekyll::Drops::Drop - # A drop representing the current page's author + # Initialize a new AuthorDrop # - # Author name will be pulled from: - # - # 1. The page's `author` key - # 2. The first author in the page's `authors` key - # 3. The `author` key in the site config - # - # If the result from the name search is a string, we'll also check - # for additional author metadata in `site.data.authors` + # page - The page hash (e.g., Page#to_liquid) + # site - The Jekyll::Drops::SiteDrop def initialize(page: nil, site: nil) - raise ArugementError unless page && site + raise ArgumentError unless page && site @mutations = {} @page = page @site = site end - # Public methods to delegate to keys of the author hash - # Ensures keys will be present when `to_h` is called, even with nil values - DELEGATED_METHODS = %i[name picture].freeze - - DELEGATED_METHODS.each do |meth| - define_method meth do - author_hash[meth.to_s] - end - end - # AuthorDrop#to_s should return name, allowing the author drop to safely # replace `page.author`, if necessary, and remain backwards compatible + def name + author_hash["name"] + end alias_method :to_s, :name def twitter diff --git a/spec/jekyll_seo_tag/author_drop_spec.rb b/spec/jekyll_seo_tag/author_drop_spec.rb new file mode 100644 index 0000000..764b2a2 --- /dev/null +++ b/spec/jekyll_seo_tag/author_drop_spec.rb @@ -0,0 +1,162 @@ +RSpec.describe Jekyll::SeoTag::AuthorDrop do + let(:data) { {} } + let(:config) { { "author" => "site_author" } } + let(:site) do + site = make_site(config) + site.data = data + site + end + let(:site_payload) { site.site_payload["site"] } + + let(:name) { "foo" } + let(:twitter) { "foo" } + let(:picture) { nil } + let(:expected_hash) do + { + "name" => name, + "twitter" => twitter, + } + end + + let(:page_meta) { { "title" => "page title" } } + let(:page) { make_page(page_meta) } + subject { described_class.new(:page => page.to_liquid, :site => site_payload.to_liquid) } + + before do + Jekyll.logger.log_level = :error + end + + it "returns the author's name for #to_s" do + expect(subject.to_s).to eql("site_author") + end + + context "with site.authors as an array" do + let("data") { { "authors" => %w(foo bar) } } + let(:page_meta) { { "author" => "foo" } } + + it "doesn't error" do + expect(subject.to_h).to eql(expected_hash) + end + end + + context "with site.authors[author] as string" do + let("data") { { "authors" => { "foo" => "bar" } } } + let(:page_meta) { { "author" => "foo" } } + + it "doesn't error" do + expect(subject.to_h).to eql(expected_hash) + end + end + + %i[with without].each do |site_data_type| + context "#{site_data_type} site.author data" do + let(:data) do + if site_data_type == :with + { + "authors" => { + "author" => { "name" => "data_author", "image" => "author.png" }, + "array_author" => { "image" => "author.png" }, + "string_author" => { "image" => "author.png" }, + "site_author" => { "image" => "author.png" }, + }, + } + else + {} + end + end + + { + :string => { "author" => "string_author" }, + :array => { "authors" => %w(array_author author2) }, + :empty_string => { "author" => "" }, + :nil => { "author" => nil }, + :hash => { "author" => { "name" => "hash_author" } }, + }.each do |author_type, data| + context "with author as #{author_type}" do + let(:page_meta) { data } + let(:expected_author) do + "#{author_type}_author".sub("nil_", "site_").sub("empty_string_", "site_") + end + + it "returns the name" do + expect(subject["name"]).to eql(expected_author) + end + + it "returns the twitter handle" do + expect(subject["twitter"]).to eql(expected_author) + end + + if site_data_type == :with && author_type != :hash + it "returns arbitrary metadata" do + expect(subject["image"]).to eql("author.png") + end + end + end + end + end + end + + context "with author as a front matter default" do + let(:config) do + { + "defaults" => [ + { + "scope" => { "path" => "" }, + "values" => { "author" => "front matter default" }, + }, + ], + } + end + + it "uses the author from the front matter default" do + expect(subject["name"]).to eql("front matter default") + end + end + + context "twitter" do + let(:page_meta) { { "author" => "author" } } + + it "pulls the handle from the author" do + expect(subject["twitter"]).to eql("author") + end + + context "with an @" do + let(:page_meta) do + { + "author" => { + "name" => "author", + "twitter" => "@twitter", + }, + } + end + + it "strips the @" do + expect(subject["twitter"]).to eql("twitter") + end + end + + # See https://github.com/jekyll/jekyll-seo-tag/issues/202 + context "without an author name or handle" do + let(:page_meta) { { "author" => { "foo" => "bar" } } } + + it "dosen't blow up" do + expect(subject["twitter"]).to be_nil + end + end + + context "with an explicit handle" do + let(:page_meta) do + { + "author" => { + "name" => "author", + "twitter" => "twitter", + }, + } + end + + it "pulls the handle from the hash" do + expect(subject["twitter"]).to eql("twitter") + end + end + end +end diff --git a/spec/jekyll_seo_tag/drop_spec.rb b/spec/jekyll_seo_tag/drop_spec.rb index 27fd406..6510e20 100644 --- a/spec/jekyll_seo_tag/drop_spec.rb +++ b/spec/jekyll_seo_tag/drop_spec.rb @@ -223,95 +223,20 @@ RSpec.describe Jekyll::SeoTag::Drop do end context "author" do - let(:name) { "foo" } - let(:twitter) { "foo" } - let(:picture) { nil } - let(:expected_hash) do - { - "name" => name, - "twitter" => twitter, - "picture" => picture, - } - end - let(:data) { {} } - let(:config) { { "author" => "site_author" } } - let(:site) do - site = make_site(config) - site.data = data - site + let(:page_meta) { { "author" => "foo" } } + + it "returns an AuthorDrop" do + expect(subject.author).to be_a(Jekyll::SeoTag::AuthorDrop) end - context "with site.authors as an array" do - let("data") { { "authors" => %w(foo bar) } } - let(:page_meta) { { "author" => "foo" } } - - it "doesn't error" do - expect(subject.author.to_h).to eql(expected_hash) - end - end - - context "with site.authors[author] as string" do - let("data") { { "authors" => { "foo" => "bar" } } } - let(:page_meta) { { "author" => "foo" } } - - it "doesn't error" do - expect(subject.author.to_h).to eql(expected_hash) - end - end - - %i[with without].each do |site_data_type| - context "#{site_data_type} site.author data" do - let(:data) do - if site_data_type == :with - { - "authors" => { - "author" => { "name" => "data_author", "image" => "author.png" }, - "array_author" => { "image" => "author.png" }, - "string_author" => { "image" => "author.png" }, - "site_author" => { "image" => "author.png" }, - }, - } - else - {} - end - end - - { - :string => { "author" => "string_author" }, - :array => { "authors" => %w(array_author author2) }, - :empty_string => { "author" => "" }, - :nil => { "author" => nil }, - :hash => { "author" => { "name" => "hash_author" } }, - }.each do |author_type, data| - context "with author as #{author_type}" do - let(:page_meta) { data } - let(:expected_author) do - "#{author_type}_author".sub("nil_", "site_").sub("empty_string_", "site_") - end - - it "returns a Drop" do - expect(subject.author).to be_a(Jekyll::SeoTag::AuthorDrop) - end - - it "returns the name" do - expect(subject.author["name"]).to eql(expected_author) - end - - it "returns the twitter handle" do - expect(subject.author["twitter"]).to eql(expected_author) - end - - if site_data_type == :with && author_type != :hash - it "returns the image" do - expect(subject.author["image"]).to eql("author.png") - end - end - end - end - end + it "passes page information" do + expect(subject.author.name).to eql("foo") end + # Regression test to ensure to_liquid is called on site and page + # before being passed to AuthorDrop context "with author as a front matter default" do + let(:page_meta) { {} } let(:config) do { "defaults" => [ @@ -327,53 +252,6 @@ RSpec.describe Jekyll::SeoTag::Drop do expect(subject.author["name"]).to eql("front matter default") end end - - context "twitter" do - let(:page_meta) { { "author" => "author" } } - - it "pulls the handle from the author" do - expect(subject.author["twitter"]).to eql("author") - end - - context "with an @" do - let(:page_meta) do - { - "author" => { - "name" => "author", - "twitter" => "@twitter", - }, - } - end - - it "strips the @" do - expect(subject.author["twitter"]).to eql("twitter") - end - end - - # See https://github.com/jekyll/jekyll-seo-tag/issues/202 - context "without an author name or handle" do - let(:page_meta) { { "author" => { "foo" => "bar" } } } - - it "dosen't blow up" do - expect(subject.author["twitter"]).to be_nil - end - end - - context "with an explicit handle" do - let(:page_meta) do - { - "author" => { - "name" => "author", - "twitter" => "twitter", - }, - } - end - - it "pulls the handle from the hash" do - expect(subject.author["twitter"]).to eql("twitter") - end - end - end end end From 1081a0ebd9a0f04d1e8411b88e5b304618423f04 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Wed, 23 Aug 2017 12:11:30 -0400 Subject: [PATCH 03/13] break image logic into its own drop --- lib/jekyll-seo-tag.rb | 2 + lib/jekyll-seo-tag/drop.rb | 35 +--------- lib/jekyll-seo-tag/image_drop.rb | 67 +++++++++++++++++++ lib/jekyll-seo-tag/json_ld.rb | 4 +- lib/jekyll-seo-tag/url_helper.rb | 14 ++++ lib/template.html | 4 +- spec/jekyll_seo_tag/drop_spec.rb | 80 ++-------------------- spec/jekyll_seo_tag/image_drop_spec.rb | 93 ++++++++++++++++++++++++++ 8 files changed, 187 insertions(+), 112 deletions(-) create mode 100644 lib/jekyll-seo-tag/image_drop.rb create mode 100644 lib/jekyll-seo-tag/url_helper.rb create mode 100644 spec/jekyll_seo_tag/image_drop_spec.rb diff --git a/lib/jekyll-seo-tag.rb b/lib/jekyll-seo-tag.rb index 44ec08b..1a50302 100644 --- a/lib/jekyll-seo-tag.rb +++ b/lib/jekyll-seo-tag.rb @@ -5,6 +5,8 @@ module Jekyll class SeoTag < Liquid::Tag autoload :JSONLD, "jekyll-seo-tag/json_ld" autoload :AuthorDrop, "jekyll-seo-tag/author_drop" + autoload :ImageDrop, "jekyll-seo-tag/image_drop" + autoload :UrlHelper, "jekyll-seo-tag/url_helper" autoload :Drop, "jekyll-seo-tag/drop" autoload :Filters, "jekyll-seo-tag/filters" diff --git a/lib/jekyll-seo-tag/drop.rb b/lib/jekyll-seo-tag/drop.rb index d6a1649..2bf89b4 100644 --- a/lib/jekyll-seo-tag/drop.rb +++ b/lib/jekyll-seo-tag/drop.rb @@ -2,6 +2,7 @@ module Jekyll class SeoTag class Drop < Jekyll::Drops::Drop include Jekyll::SeoTag::JSONLD + include Jekyll::SeoTag::UrlHelper TITLE_SEPARATOR = " | ".freeze FORMAT_STRING_METHODS = %i[ @@ -129,33 +130,8 @@ module Jekyll end end - # Returns nil or a hash representing the page image - # The image hash will always contain a path, pulled from: - # - # 1. The `image` key if it's a string - # 2. The `image.path` key if it's a hash - # 3. The `image.facebook` key - # 4. The `image.twitter` key - # - # The resulting path is always an absolute URL def image - return @image if defined?(@image) - - image = page["image"] - return @image = nil unless image - - image = { "path" => image } if image.is_a?(String) - image["path"] ||= image["facebook"] || image["twitter"] - return @image = nil unless image["path"] - - # absolute_url? will return nil for an invalid URL - if absolute_url?(image["path"]) == false - image["path"] = filters.absolute_url image["path"] - end - - image["path"] = filters.uri_escape image["path"] - - @image = image.to_liquid + @image ||= ImageDrop.new(:page => page, :context => @context) end def page_lang @@ -196,13 +172,6 @@ module Jekyll @fallback_data ||= {} end - def absolute_url?(string) - return unless string - Addressable::URI.parse(string).absolute? - rescue Addressable::URI::InvalidURIError - nil - end - def format_string(string) string = FORMAT_STRING_METHODS.reduce(string) do |memo, method| filters.public_send(method, memo) diff --git a/lib/jekyll-seo-tag/image_drop.rb b/lib/jekyll-seo-tag/image_drop.rb new file mode 100644 index 0000000..5893103 --- /dev/null +++ b/lib/jekyll-seo-tag/image_drop.rb @@ -0,0 +1,67 @@ +module Jekyll + class SeoTag + # Returns nil or a hash representing the page image + # The image hash will always contain a path, pulled from: + # + # 1. The `image` key if it's a string + # 2. The `image.path` key if it's a hash + # 3. The `image.facebook` key + # 4. The `image.twitter` key + # + # The resulting path is always an absolute URL + class ImageDrop < Jekyll::Drops::Drop + include Jekyll::SeoTag::UrlHelper + + # Initialize a new ImageDrop + # + # page - The page hash (e.g., Page#to_liquid) + def initialize(page: nil, context: nil) + raise ArgumentError unless page && context + @mutations = {} + @page = page + @context = context + end + + def path + @path ||= filters.uri_escape(absolute_url) if absolute_url + end + alias_method :to_s, :path + + private + + attr_accessor :page + attr_accessor :context + + def image_hash + @image_hash ||= if page["image"].is_a?(Hash) + page["image"] + elsif page["image"].is_a?(String) + { "path" => page["image"] } + else + { "path" => nil } + end + end + alias_method :fallback_data, :image_hash + + def raw_path + @raw_path ||= begin + image_hash["path"] || image_hash["facebook"] || image_hash["twitter"] + end + end + + def absolute_url + return unless raw_path + return @absolute_url if defined? @absolute_url + @absolute_url = if raw_path.is_a?(String) && absolute_url?(raw_path) == false + filters.absolute_url raw_path + else + raw_path + end + end + + def filters + @filters ||= Jekyll::SeoTag::Filters.new(context) + end + end + end +end diff --git a/lib/jekyll-seo-tag/json_ld.rb b/lib/jekyll-seo-tag/json_ld.rb index 318685f..c097770 100644 --- a/lib/jekyll-seo-tag/json_ld.rb +++ b/lib/jekyll-seo-tag/json_ld.rb @@ -46,9 +46,9 @@ module Jekyll def json_image return unless image - return image["path"] if image.length == 1 + return image["path"] if image.keys.length == 1 - hash = image.dup + hash = image.to_h hash["url"] = hash.delete("path") hash["@type"] = "imageObject" hash diff --git a/lib/jekyll-seo-tag/url_helper.rb b/lib/jekyll-seo-tag/url_helper.rb new file mode 100644 index 0000000..5deb581 --- /dev/null +++ b/lib/jekyll-seo-tag/url_helper.rb @@ -0,0 +1,14 @@ +module Jekyll + class SeoTag + module UrlHelper + private + + def absolute_url?(string) + return unless string + Addressable::URI.parse(string).absolute? + rescue Addressable::URI::InvalidURIError + nil + end + end + end +end diff --git a/lib/template.html b/lib/template.html index d51169b..6d5f10c 100755 --- a/lib/template.html +++ b/lib/template.html @@ -27,7 +27,7 @@ {% endif %} -{% if seo_tag.image %} +{% if seo_tag.image.path %} {% if seo_tag.image.height %} @@ -50,7 +50,7 @@ {% endif %} {% if site.twitter %} - {% if seo_tag.image %} + {% if seo_tag.image.path %} {% else %} diff --git a/spec/jekyll_seo_tag/drop_spec.rb b/spec/jekyll_seo_tag/drop_spec.rb index 6510e20..2f9ca07 100644 --- a/spec/jekyll_seo_tag/drop_spec.rb +++ b/spec/jekyll_seo_tag/drop_spec.rb @@ -402,85 +402,15 @@ RSpec.describe Jekyll::SeoTag::Drop do end context "image" do + let(:image) { "foo.png" } let(:page_meta) { { "image" => image } } - context "with image as a string" do - let(:image) { "image.png" } - - it "returns a hash" do - expect(subject.image).to be_a(Hash) - end - - it "returns the image" do - expect(subject.image["path"]).to eql("/image.png") - end - - context "with site.url" do - let(:config) { { "url" => "http://example.com" } } - - it "makes the path absolute" do - expect(subject.image["path"]).to eql("http://example.com/image.png") - end - end - - context "with a URL-escaped path" do - let(:image) { "some image.png" } - - it "URL-escapes the image" do - expect(subject.image["path"]).to eql("/some%20image.png") - end - end + it "returns a Drop" do + expect(subject.image).to be_a(Jekyll::SeoTag::ImageDrop) end - context "with image as a hash" do - context "with a path" do - let(:image) { { "path" => "image.png" } } - - it "returns the image" do - expect(subject.image["path"]).to eql("/image.png") - end - end - - context "with facebook" do - let(:image) { { "facebook" => "image.png" } } - - it "returns the image" do - expect(subject.image["path"]).to eql("/image.png") - end - end - - context "with twitter" do - let(:image) { { "twitter" => "image.png" } } - - it "returns the image" do - expect(subject.image["path"]).to eql("/image.png") - end - end - - context "with some random hash" do - let(:image) { { "foo" => "bar" } } - - it "returns nil" do - expect(subject.image).to be_nil - end - end - - context "with an invalid path" do - let(:image) { ":" } - - it "returns nil" do - expect(subject.image["path"]).to eql(":") - end - end - - context "with height and width" do - let(:image) { { "path" => "image.png", "height" => 5, "width" => 10 } } - - it "returns the height and width" do - expect(subject.image["height"]).to eql(5) - expect(subject.image["width"]).to eql(10) - end - end + it "returns the image" do + expect(subject.image["path"]).to eql("/foo.png") end end diff --git a/spec/jekyll_seo_tag/image_drop_spec.rb b/spec/jekyll_seo_tag/image_drop_spec.rb new file mode 100644 index 0000000..f8f2507 --- /dev/null +++ b/spec/jekyll_seo_tag/image_drop_spec.rb @@ -0,0 +1,93 @@ +RSpec.describe Jekyll::SeoTag::ImageDrop do + let(:config) { { "title" => "site title" } } + let(:image) { nil } + let(:page_meta) { { "image" => image } } + let(:page) { make_page(page_meta) } + let(:site) { make_site(config) } + let(:context) { make_context(:page => page, :site => site) } + let(:text) { "" } + subject { described_class.new(:page => page.to_liquid, :context => context) } + + before do + Jekyll.logger.log_level = :error + end + + context "with image as a string" do + let(:image) { "image.png" } + + it "returns the image" do + expect(subject["path"]).to eql("/image.png") + end + + context "with site.url" do + let(:config) { { "url" => "http://example.com" } } + + it "makes the path absolute" do + expect(subject["path"]).to eql("http://example.com/image.png") + end + end + + context "with a URL-escaped path" do + let(:image) { "some image.png" } + + it "URL-escapes the image" do + expect(subject["path"]).to eql("/some%20image.png") + end + end + end + + context "with image as a hash" do + context "with a path" do + let(:image) { { "path" => "image.png" } } + + it "returns the image" do + expect(subject["path"]).to eql("/image.png") + end + end + + context "with facebook" do + let(:image) { { "facebook" => "image.png" } } + + it "returns the image" do + expect(subject["path"]).to eql("/image.png") + end + end + + context "with twitter" do + let(:image) { { "twitter" => "image.png" } } + + it "returns the image" do + expect(subject["path"]).to eql("/image.png") + end + end + + context "with some random hash" do + let(:image) { { "foo" => "bar" } } + + it "returns nil" do + expect(subject["path"]).to be_nil + end + + it "returns arbitrary values" do + expect(subject["foo"]).to eql("bar") + end + end + + context "with an invalid path" do + let(:image) { ":" } + + it "returns the path" do + expect(subject["path"]).to eql(":") + end + end + + context "with height and width" do + let(:image) { { "path" => "image.png", "height" => 5, "width" => 10 } } + + it "returns the height and width" do + expect(subject["height"]).to eql(5) + expect(subject["width"]).to eql(10) + end + end + end +end From 298d3b03d61fe8651773705be4839d074b218425 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Wed, 23 Aug 2017 12:18:52 -0400 Subject: [PATCH 04/13] Drop#image should return nil if there is no image#path in order to avoid a breaking change --- lib/jekyll-seo-tag/drop.rb | 3 +++ lib/jekyll-seo-tag/image_drop.rb | 13 ++++++++----- lib/jekyll-seo-tag/url_helper.rb | 6 ++++++ lib/template.html | 4 ++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/jekyll-seo-tag/drop.rb b/lib/jekyll-seo-tag/drop.rb index 2bf89b4..2561664 100644 --- a/lib/jekyll-seo-tag/drop.rb +++ b/lib/jekyll-seo-tag/drop.rb @@ -130,8 +130,11 @@ module Jekyll end end + # Returns a Drop representing the page's image + # Returns nil if the image has no path, to preserve backwards compatability def image @image ||= ImageDrop.new(:page => page, :context => @context) + @image if @image.path end def page_lang diff --git a/lib/jekyll-seo-tag/image_drop.rb b/lib/jekyll-seo-tag/image_drop.rb index 5893103..2bffa92 100644 --- a/lib/jekyll-seo-tag/image_drop.rb +++ b/lib/jekyll-seo-tag/image_drop.rb @@ -1,20 +1,19 @@ module Jekyll class SeoTag - # Returns nil or a hash representing the page image - # The image hash will always contain a path, pulled from: + # A drop representing the page image + # The image path will be pulled from: # # 1. The `image` key if it's a string # 2. The `image.path` key if it's a hash # 3. The `image.facebook` key # 4. The `image.twitter` key - # - # The resulting path is always an absolute URL class ImageDrop < Jekyll::Drops::Drop include Jekyll::SeoTag::UrlHelper # Initialize a new ImageDrop # # page - The page hash (e.g., Page#to_liquid) + # context - the Liquid::Context def initialize(page: nil, context: nil) raise ArgumentError unless page && context @mutations = {} @@ -22,6 +21,9 @@ module Jekyll @context = context end + # Called path for backwards compatability, this is really + # the escaped, absolute URL representing the page's image + # Returns nil if no image path can be determined def path @path ||= filters.uri_escape(absolute_url) if absolute_url end @@ -32,9 +34,10 @@ module Jekyll attr_accessor :page attr_accessor :context + # The normalized image hash with a `path` key (which may be nil) def image_hash @image_hash ||= if page["image"].is_a?(Hash) - page["image"] + { "path" => nil }.merge(page["image"]) elsif page["image"].is_a?(String) { "path" => page["image"] } else diff --git a/lib/jekyll-seo-tag/url_helper.rb b/lib/jekyll-seo-tag/url_helper.rb index 5deb581..d8d799b 100644 --- a/lib/jekyll-seo-tag/url_helper.rb +++ b/lib/jekyll-seo-tag/url_helper.rb @@ -1,8 +1,14 @@ module Jekyll class SeoTag + # Mixin to share common URL-related methods between class module UrlHelper private + # Determines if the given string is an absolute URL + # + # Returns true if an absolute URL. + # Retruns false if it's a relative URL + # Returns nil if it is not a string or can't be parsed as a URL def absolute_url?(string) return unless string Addressable::URI.parse(string).absolute? diff --git a/lib/template.html b/lib/template.html index 6d5f10c..d51169b 100755 --- a/lib/template.html +++ b/lib/template.html @@ -27,7 +27,7 @@ {% endif %} -{% if seo_tag.image.path %} +{% if seo_tag.image %} {% if seo_tag.image.height %} @@ -50,7 +50,7 @@ {% endif %} {% if site.twitter %} - {% if seo_tag.image.path %} + {% if seo_tag.image %} {% else %} From 5de6cd7f2c15b2d6ac8a6835080ae9bc6565bd22 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Wed, 23 Aug 2017 16:11:55 -0400 Subject: [PATCH 05/13] convert JSON LD to a drop --- lib/jekyll-seo-tag.rb | 11 ++-- lib/jekyll-seo-tag/drop.rb | 20 ++++--- lib/jekyll-seo-tag/jason_ld_drop.rb | 79 +++++++++++++++++++++++++ lib/jekyll-seo-tag/json_ld.rb | 59 +----------------- spec/jekyll_seo_tag_integration_spec.rb | 2 +- spec/spec_helper.rb | 9 +++ 6 files changed, 108 insertions(+), 72 deletions(-) create mode 100644 lib/jekyll-seo-tag/jason_ld_drop.rb diff --git a/lib/jekyll-seo-tag.rb b/lib/jekyll-seo-tag.rb index 1a50302..6d84dfb 100644 --- a/lib/jekyll-seo-tag.rb +++ b/lib/jekyll-seo-tag.rb @@ -3,12 +3,13 @@ require "jekyll-seo-tag/version" module Jekyll class SeoTag < Liquid::Tag - autoload :JSONLD, "jekyll-seo-tag/json_ld" + autoload :JSONLD, "jekyll-seo-tag/json_ld" autoload :AuthorDrop, "jekyll-seo-tag/author_drop" - autoload :ImageDrop, "jekyll-seo-tag/image_drop" - autoload :UrlHelper, "jekyll-seo-tag/url_helper" - autoload :Drop, "jekyll-seo-tag/drop" - autoload :Filters, "jekyll-seo-tag/filters" + autoload :ImageDrop, "jekyll-seo-tag/image_drop" + autoload :JSONLDDrop, "jekyll-seo-tag/jason_ld_drop" + autoload :UrlHelper, "jekyll-seo-tag/url_helper" + autoload :Drop, "jekyll-seo-tag/drop" + autoload :Filters, "jekyll-seo-tag/filters" attr_accessor :context diff --git a/lib/jekyll-seo-tag/drop.rb b/lib/jekyll-seo-tag/drop.rb index 2561664..a554201 100644 --- a/lib/jekyll-seo-tag/drop.rb +++ b/lib/jekyll-seo-tag/drop.rb @@ -1,7 +1,6 @@ module Jekyll class SeoTag class Drop < Jekyll::Drops::Drop - include Jekyll::SeoTag::JSONLD include Jekyll::SeoTag::UrlHelper TITLE_SEPARATOR = " | ".freeze @@ -78,6 +77,18 @@ module Jekyll @author ||= AuthorDrop.new(:page => page, :site => site) end + # A drop representing the JSON-LD output + def json_ld + @json_ld ||= JSONLDDrop.new(self) + end + + # Returns a Drop representing the page's image + # Returns nil if the image has no path, to preserve backwards compatability + def image + @image ||= ImageDrop.new(:page => page, :context => @context) + @image if @image.path + end + def date_modified @date_modified ||= begin date = if page_seo["date_modified"] @@ -130,13 +141,6 @@ module Jekyll end end - # Returns a Drop representing the page's image - # Returns nil if the image has no path, to preserve backwards compatability - def image - @image ||= ImageDrop.new(:page => page, :context => @context) - @image if @image.path - end - def page_lang @page_lang ||= page["lang"] || site["lang"] || "en_US" end diff --git a/lib/jekyll-seo-tag/jason_ld_drop.rb b/lib/jekyll-seo-tag/jason_ld_drop.rb new file mode 100644 index 0000000..22c2e8b --- /dev/null +++ b/lib/jekyll-seo-tag/jason_ld_drop.rb @@ -0,0 +1,79 @@ +module Jekyll + class SeoTag + class JSONLDDrop < Jekyll::Drops::Drop + extend Forwardable + + def_delegator :page_drop, :name, :name + def_delegator :page_drop, :description, :description + def_delegator :page_drop, :canonical_url, :url + def_delegator :page_drop, :page_title, :headline + def_delegator :page_drop, :date_modified, :dateModified + def_delegator :page_drop, :date_published, :datePublished + def_delegator :page_drop, :links, :sameAs + def_delegator :page_drop, :logo, :logo + + # Expose #type and #logo and private methods and #@type as a public method + def_delegator :page_drop, :type, :type + alias_method :"@type", :type + private :type + private :logo + + # page_drop should be an instance of Jekyll::SeoTag::Drop + def initialize(page_drop) + @mutations = {} + @page_drop = page_drop + end + + def fallback_data + { + "@context" => "http://schema.org", + } + end + + def author + return unless page_drop.author["name"] + { + "@type" => "Person", + "name" => page_drop.author["name"], + } + end + + 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 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 main_entity + return unless %w(BlogPosting CreativeWork).include?(type) + { + "@type" => "WebPage", + "@id" => page_drop.canonical_url, + } + end + alias_method :mainEntityOfPage, :main_entity + private :main_entity + + private + + attr_reader :page_drop + end + end +end diff --git a/lib/jekyll-seo-tag/json_ld.rb b/lib/jekyll-seo-tag/json_ld.rb index c097770..7ac993e 100644 --- a/lib/jekyll-seo-tag/json_ld.rb +++ b/lib/jekyll-seo-tag/json_ld.rb @@ -1,8 +1,7 @@ module Jekyll class SeoTag module JSONLD - - # A hash of instance methods => key in resulting JSON-LD hash + # Unused, but here to preserve backwards compatability METHODS_KEYS = { :json_context => "@context", :type => "@type", @@ -18,62 +17,6 @@ module Jekyll :links => "sameAs", :canonical_url => "url", }.freeze - - 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 - - private - - def json_context - "http://schema.org" - end - - def json_author - return unless author - { - "@type" => "Person", - "name" => author["name"], - } - end - - def json_image - return unless image - return image["path"] if image.keys.length == 1 - - hash = image.to_h - hash["url"] = hash.delete("path") - hash["@type"] = "imageObject" - hash - end - - def publisher - return unless logo - output = { - "@type" => "Organization", - "logo" => { - "@type" => "ImageObject", - "url" => logo, - }, - } - output["name"] = author["name"] if author - output - end - - def main_entity - return unless %w(BlogPosting CreativeWork).include?(type) - { - "@type" => "WebPage", - "@id" => canonical_url, - } - end end end end diff --git a/spec/jekyll_seo_tag_integration_spec.rb b/spec/jekyll_seo_tag_integration_spec.rb index a0f3ca8..81278b8 100755 --- a/spec/jekyll_seo_tag_integration_spec.rb +++ b/spec/jekyll_seo_tag_integration_spec.rb @@ -330,7 +330,7 @@ EOS it "minifies JSON-LD" do expected = <<-EOS.strip -{"@context":"http://schema.org","@type":"BlogPosting","headline":"post", +{"name":null,"description":"description","author":null,"@type":"BlogPosting" EOS expect(output).to match(expected) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bbb2756..81ab4ab 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,6 +3,15 @@ require "jekyll" require "jekyll-seo-tag" require "html-proofer" +# Monkey patch Jekyll::Drops::Drop so Rspec's `have_key` works as expected +module Jekyll + module Drops + class Drop + alias_method :has_key?, :key? + end + end +end + ENV["JEKYLL_LOG_LEVEL"] = "error" def dest_dir From cf49c63b3c5e168f4b01af0269b1b63faf230384 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Wed, 23 Aug 2017 16:20:02 -0400 Subject: [PATCH 06/13] add tests for JSON-LD drop --- spec/jekyll_seo_tag/drop_spec.rb | 4 ++++ spec/jekyll_seo_tag/json_ld_spec.rb | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/spec/jekyll_seo_tag/drop_spec.rb b/spec/jekyll_seo_tag/drop_spec.rb index 2f9ca07..4fa5a22 100644 --- a/spec/jekyll_seo_tag/drop_spec.rb +++ b/spec/jekyll_seo_tag/drop_spec.rb @@ -479,4 +479,8 @@ RSpec.describe Jekyll::SeoTag::Drop do end end end + + it "exposes the JSON-LD drop" do + expect(subject.json_ld).to be_a(Jekyll::SeoTag::JSONLDDrop) + end end diff --git a/spec/jekyll_seo_tag/json_ld_spec.rb b/spec/jekyll_seo_tag/json_ld_spec.rb index 88b987a..8452b62 100644 --- a/spec/jekyll_seo_tag/json_ld_spec.rb +++ b/spec/jekyll_seo_tag/json_ld_spec.rb @@ -1,8 +1,4 @@ -RSpec.describe Jekyll::SeoTag::JSONLD do - before do - Jekyll.logger.log_level = :error - end - +RSpec.describe Jekyll::SeoTag::JSONLDDrop do let(:author) { "author" } let(:image) { "image" } let(:metadata) do @@ -28,7 +24,12 @@ RSpec.describe Jekyll::SeoTag::JSONLD do let(:page) { make_page(metadata) } let(:site) { make_site(config) } let(:context) { make_context(:page => page, :site => site) } - subject { Jekyll::SeoTag::Drop.new("", context).json_ld } + let(:page_drop) { Jekyll::SeoTag::Drop.new("", context) } + subject { described_class.new(page_drop) } + + before do + Jekyll.logger.log_level = :error + end it "returns the context" do expect(subject).to have_key("@context") From 5219dd13e6e2a9dee91c9f7a69f1eee8edfe61cd Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Wed, 23 Aug 2017 16:25:28 -0400 Subject: [PATCH 07/13] drop the a, just JSON --- lib/jekyll-seo-tag.rb | 2 +- lib/jekyll-seo-tag/{jason_ld_drop.rb => json_ld_drop.rb} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/jekyll-seo-tag/{jason_ld_drop.rb => json_ld_drop.rb} (100%) diff --git a/lib/jekyll-seo-tag.rb b/lib/jekyll-seo-tag.rb index 6d84dfb..5ba8aad 100644 --- a/lib/jekyll-seo-tag.rb +++ b/lib/jekyll-seo-tag.rb @@ -6,7 +6,7 @@ module Jekyll autoload :JSONLD, "jekyll-seo-tag/json_ld" autoload :AuthorDrop, "jekyll-seo-tag/author_drop" autoload :ImageDrop, "jekyll-seo-tag/image_drop" - autoload :JSONLDDrop, "jekyll-seo-tag/jason_ld_drop" + autoload :JSONLDDrop, "jekyll-seo-tag/json_ld_drop" autoload :UrlHelper, "jekyll-seo-tag/url_helper" autoload :Drop, "jekyll-seo-tag/drop" autoload :Filters, "jekyll-seo-tag/filters" diff --git a/lib/jekyll-seo-tag/jason_ld_drop.rb b/lib/jekyll-seo-tag/json_ld_drop.rb similarity index 100% rename from lib/jekyll-seo-tag/jason_ld_drop.rb rename to lib/jekyll-seo-tag/json_ld_drop.rb From 792abad221bdf41d125b2949fbff1d898813e69b Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Wed, 23 Aug 2017 16:42:05 -0400 Subject: [PATCH 08/13] make the json minification test less order dependent --- spec/jekyll_seo_tag_integration_spec.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/jekyll_seo_tag_integration_spec.rb b/spec/jekyll_seo_tag_integration_spec.rb index 81278b8..78b6fc0 100755 --- a/spec/jekyll_seo_tag_integration_spec.rb +++ b/spec/jekyll_seo_tag_integration_spec.rb @@ -329,9 +329,7 @@ EOS end it "minifies JSON-LD" do - expected = <<-EOS.strip -{"name":null,"description":"description","author":null,"@type":"BlogPosting" -EOS + expected = '{"name":null,"description":"description"' expect(output).to match(expected) end end From 855ef7b4690493dff97503a0fc4c14eeb2f6257b Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Wed, 23 Aug 2017 16:44:33 -0400 Subject: [PATCH 09/13] make the json minification spec explicit --- spec/jekyll_seo_tag_integration_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/jekyll_seo_tag_integration_spec.rb b/spec/jekyll_seo_tag_integration_spec.rb index 78b6fc0..016fdae 100755 --- a/spec/jekyll_seo_tag_integration_spec.rb +++ b/spec/jekyll_seo_tag_integration_spec.rb @@ -329,8 +329,7 @@ EOS end it "minifies JSON-LD" do - expected = '{"name":null,"description":"description"' - expect(output).to match(expected) + expect(output).to_not match(/{.*?\s.*?}/) end end end From 3ef2f613e9edf9242e9f1075c4bf9dcba36b74ef Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Wed, 23 Aug 2017 16:50:23 -0400 Subject: [PATCH 10/13] fix regex syntax --- spec/jekyll_seo_tag_integration_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/jekyll_seo_tag_integration_spec.rb b/spec/jekyll_seo_tag_integration_spec.rb index 016fdae..22dcd08 100755 --- a/spec/jekyll_seo_tag_integration_spec.rb +++ b/spec/jekyll_seo_tag_integration_spec.rb @@ -329,7 +329,7 @@ EOS end it "minifies JSON-LD" do - expect(output).to_not match(/{.*?\s.*?}/) + expect(output).to_not match(%r!{.*?\s.*?}!) end end end From 83d420113ca05ab3340cd5561cbe11f9d987023b Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Thu, 24 Aug 2017 13:01:43 -0400 Subject: [PATCH 11/13] add json_ld back to JSONLD to avoid a breaking change --- lib/jekyll-seo-tag/json_ld.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/jekyll-seo-tag/json_ld.rb b/lib/jekyll-seo-tag/json_ld.rb index 7ac993e..b00ce29 100644 --- a/lib/jekyll-seo-tag/json_ld.rb +++ b/lib/jekyll-seo-tag/json_ld.rb @@ -1,7 +1,8 @@ module Jekyll class SeoTag + # This module is deprecated, but is included in the Gem to avoid a breaking + # change and should be removed at the next major version bump module JSONLD - # Unused, but here to preserve backwards compatability METHODS_KEYS = { :json_context => "@context", :type => "@type", @@ -17,6 +18,12 @@ module Jekyll :links => "sameAs", :canonical_url => "url", }.freeze + + # Self should be a Jekyll::SeoTag::Drop instance (when extending the module) + def json_ld + Jekyll.logger.warn "Jekyll::SeoTag::JSONLD is deprecated" + @json_ld ||= JSONLDDrop.new(self) + end end end end From 1e5b9979019b2157e3f5b6c86b3473d19f196c56 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Thu, 24 Aug 2017 13:05:28 -0400 Subject: [PATCH 12/13] typo in code comment --- lib/jekyll-seo-tag/json_ld_drop.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll-seo-tag/json_ld_drop.rb b/lib/jekyll-seo-tag/json_ld_drop.rb index 22c2e8b..85fea10 100644 --- a/lib/jekyll-seo-tag/json_ld_drop.rb +++ b/lib/jekyll-seo-tag/json_ld_drop.rb @@ -12,7 +12,7 @@ module Jekyll def_delegator :page_drop, :links, :sameAs def_delegator :page_drop, :logo, :logo - # Expose #type and #logo and private methods and #@type as a public method + # Expose #type and #logo as private methods and #@type as a public method def_delegator :page_drop, :type, :type alias_method :"@type", :type private :type From d79dac001e3ed4dd81e9afe879f04a369738dea8 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Thu, 24 Aug 2017 13:05:56 -0400 Subject: [PATCH 13/13] whitespace --- lib/jekyll-seo-tag/json_ld_drop.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll-seo-tag/json_ld_drop.rb b/lib/jekyll-seo-tag/json_ld_drop.rb index 85fea10..3f88be0 100644 --- a/lib/jekyll-seo-tag/json_ld_drop.rb +++ b/lib/jekyll-seo-tag/json_ld_drop.rb @@ -11,9 +11,9 @@ module Jekyll def_delegator :page_drop, :date_published, :datePublished def_delegator :page_drop, :links, :sameAs def_delegator :page_drop, :logo, :logo + def_delegator :page_drop, :type, :type # Expose #type and #logo as private methods and #@type as a public method - def_delegator :page_drop, :type, :type alias_method :"@type", :type private :type private :logo