Make page.image url relative to site rather than absolute

This commit is contained in:
Bo Turnbow 2016-02-03 10:17:04 -07:00
parent 05a16f48b7
commit 244802ed89
3 changed files with 6 additions and 5 deletions

View File

@ -69,5 +69,5 @@ The SEO tag will respect the following YAML front matter if included in a post,
* `title` - The title of the post, page, or document
* `description` - A short description of the page's content
* `image` - The absolute URL to an image that should be associated with the post, page, or document
* `image` - Relative URL to an image associated with the post, page, or document (e.g., `assets/page-pic.jpg`)
* `author` - The username of the post, page, or document author

View File

@ -94,7 +94,7 @@
{% endif %}
{% if page.image %}
<meta property="og:image" content="{{ page.image }}" />
<meta property="og:image" content="{{ page.image | prepend: "/" | prepend: seo_url | escape }}" />
{% endif %}
{% if page.date %}

View File

@ -153,9 +153,10 @@ describe Jekyll::SeoTag do
end
it "outputs the image" do
page = page({"image" => "http://foo.invalid/foo.png"})
context = context({ :page => page })
expected = /<meta property="og:image" content="http:\/\/foo.invalid\/foo.png" \/>/
page = page({ "image" => "foo.png" })
site = site({ "url" => "http://example.invalid" })
context = context({ :page => page, :site => site })
expected = %r!<meta property="og:image" content="http://example.invalid/foo.png" />!
expect(subject.render(context)).to match(expected)
end