Merge pull request #26 from benbalter/author
Allow author data as an object
This commit is contained in:
commit
9f0b656c1f
|
@ -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 %}
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
|
Loading…
Reference in New Issue