diff --git a/lib/template.html b/lib/template.html index 85e9226..7b7e69b 100644 --- a/lib/template.html +++ b/lib/template.html @@ -44,6 +44,23 @@ {% assign seo_description = seo_description | markdownify | strip_html | strip_newlines | escape_once %} {% endif %} +{% if page.author %} + {% if page.author.name %} + {% assign seo_author_name = page.author.name %} + {% else %} + {% assign seo_author_name = page.author %} + {% endif %} + + {% if page.author.twitter %} + {% assign seo_author_twitter = page.author.twitter %} + {% else %} + {% assign seo_author_twitter = page.author %} + {% endif %} +{% endif %} +{% if seo_author_twitter %} + {% assign seo_author_twitter = seo_author_twitter | replace:"@","" | prepend:"@" %} +{% endif %} + {% if seo_title %} {{ seo_title }} {% endif %} @@ -106,8 +123,8 @@ {% if page.image %} {% endif %} - {% if page.author %} - + {% if seo_author_twitter %} + {% endif %} {% endif %} diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index bbc83cb..ada5b33 100644 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -166,6 +166,14 @@ describe Jekyll::SeoTag do expect(subject.render(context)).to match(expected) end + it "supports author data as an object" do + site = site({"twitter" => { "username" => "jekyllrb" }}) + page = page({"author" => {"twitter" => "@test"}}) + context = context({ :site => site, :page => page }) + expected = %r!! + expect(subject.render(context)).to match(expected) + end + it "outputs valid HTML" do site.process options = {