Skip to content

Commit 5ed2ab3

Browse files
committed
Merge pull request #44 from boturnbow/relative_image_tag
Make page.image url relative to site rather than absolute
2 parents 31dc249 + 244802e commit 5ed2ab3

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,5 @@ The SEO tag will respect the following YAML front matter if included in a post,
6969

7070
* `title` - The title of the post, page, or document
7171
* `description` - A short description of the page's content
72-
* `image` - The absolute URL to an image that should be associated with the post, page, or document
72+
* `image` - Relative URL to an image associated with the post, page, or document (e.g., `assets/page-pic.jpg`)
7373
* `author` - The username of the post, page, or document author

lib/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
{% endif %}
9595

9696
{% if page.image %}
97-
<meta property="og:image" content="{{ page.image }}" />
97+
<meta property="og:image" content="{{ page.image | prepend: "/" | prepend: seo_url | escape }}" />
9898
{% endif %}
9999

100100
{% if page.date %}

spec/jekyll_seo_tag_spec.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,10 @@
153153
end
154154

155155
it "outputs the image" do
156-
page = page({"image" => "http://foo.invalid/foo.png"})
157-
context = context({ :page => page })
158-
expected = /<meta property="og:image" content="http:\/\/foo.invalid\/foo.png" \/>/
156+
page = page({ "image" => "foo.png" })
157+
site = site({ "url" => "http://example.invalid" })
158+
context = context({ :page => page, :site => site })
159+
expected = %r!<meta property="og:image" content="http://example.invalid/foo.png" />!
159160
expect(subject.render(context)).to match(expected)
160161
end
161162

0 commit comments

Comments
 (0)