Merge pull request #34 from benbalter/default-to-post-excerpt

use the page.excerpt if the page.description doesn't exist
This commit is contained in:
Parker Moore 2016-01-25 16:19:06 -08:00
commit dee4a81b68
2 changed files with 10 additions and 1 deletions

View File

@ -37,6 +37,8 @@
{% if page.description %}
{% assign seo_description = page.description %}
{% elsif page.excerpt %}
{% assign seo_description = page.excerpt %}
{% elsif site.description %}
{% assign seo_description = site.description %}
{% endif %}

View File

@ -39,7 +39,14 @@ describe Jekyll::SeoTag do
expect(subject.render(context)).to match(/<meta property='og:description' content="foo" \/>/)
end
it "uses the site description when no page description exists" do
it "uses the page excerpt when no page description exists" do
page = page({"description" => "foobar"})
context = context({ :page => page })
expect(subject.render(context)).to match(/<meta name="description" content="foobar" \/>/)
expect(subject.render(context)).to match(/<meta property='og:description' content="foobar" \/>/)
end
it "uses the site description when no page description nor excerpt exist" do
site = site({"description" => "foo"})
context = context({ :site => site })
expect(subject.render(context)).to match(/<meta name="description" content="foo" \/>/)