From fd5246a4cdf3c3c93cb21e947bcef6910d5a0b14 Mon Sep 17 00:00:00 2001 From: kyle Date: Wed, 25 Jan 2017 11:05:38 -0500 Subject: [PATCH] Test output manually with Google Markup. Change inferred type. Improve test coverage --- lib/template.html | 7 +++++-- spec/jekyll_seo_tag_spec.rb | 12 +++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/template.html b/lib/template.html index 2bce881..5a28563 100644 --- a/lib/template.html +++ b/lib/template.html @@ -63,7 +63,7 @@ {% endif %} {% assign seo_author_twitter = seo_author_twitter | replace:"@","" %} {% if seo_author %} - {% assign seo_author_name = seo_author %} + {% assign seo_author_name = seo_author.name | default: seo_author %} {% endif %} {% endif %} @@ -210,7 +210,10 @@ {% endif %} {% if seo_author_name %} - "author": {{ seo_author_name | jsonify }}, + "author": { + "@type": "Person", + "name": {{ seo_author_name | jsonify }} + }, {% endif %} {% if seo_page_image %} diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index 61c5b43..a065e7f 100644 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -226,12 +226,13 @@ describe Jekyll::SeoTag do end end - context "with page.author" do + context "with page.author.name" do let(:site) { make_site("logo" => "/logo.png", "url" => "http://example.invalid") } let(:page) { make_post("author" => "Mr. Foo") } it "outputs the author" do - expect(json_data["author"]).to eql("Mr. Foo") + expect(json_data["author"]["@type"]).to eql("Person") + expect(json_data["author"]["name"]).to eql("Mr. Foo") end it "outputs the publisher author" do @@ -239,12 +240,13 @@ describe Jekyll::SeoTag do end end - context "with page.author" do + context "with only page.author" do let(:site) { make_site("logo" => "/logo.png", "url" => "http://example.invalid") } - let(:page) { make_post("author" => "Mr. Foo") } + let(:page) { make_post("author" => { "name" => "Mr. Foo" }) } it "outputs the author" do - expect(json_data["author"]).to eql("Mr. Foo") + expect(json_data["author"]["@type"]).to eql("Person") + expect(json_data["author"]["name"]).to eql("Mr. Foo") end it "outputs the publisher author" do