Merge pull request #26 from benbalter/author

Allow author data as an object
This commit is contained in:
Ben Balter 2016-01-19 19:23:20 -05:00
commit 9f0b656c1f
2 changed files with 27 additions and 2 deletions

View File

@ -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 %}
<title>{{ seo_title }}</title>
{% endif %}
@ -106,8 +123,8 @@
{% if page.image %}
<meta name="twitter:image" content="{{ page.image | escape }}" />
{% endif %}
{% if page.author %}
<meta name="twitter:creator" content="@{{ page.author | replace:"@","" }}" />
{% if seo_author_twitter %}
<meta name="twitter:creator" content="{{ seo_author_twitter }}" />
{% endif %}
{% endif %}

View File

@ -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!<meta name="twitter:creator" content="@test" />!
expect(subject.render(context)).to match(expected)
end
it "outputs valid HTML" do
site.process
options = {