Skip to content

Commit 27f2030

Browse files
authored
fix(books): properly set og:image for books (#492)
1 parent 8712a7c commit 27f2030

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

_includes/head.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
{{ site.title | escape }}
1414
{% endif %}
1515
{% endcapture %}
16+
17+
{% if page.path contains 'books' %}
18+
<!-- Twitter card image for books -->
19+
{% capture slugTitle %}{{ page.title | slugify }}{% endcapture %}
20+
{% capture folderPath %}/assets/images/bitcoin/books{% endcapture %}
21+
{% capture cardImageUrl %}{{ folderPath }}/jpg/{{ slugTitle }}.jpg{% endcapture %}
22+
23+
<!-- Description for twitter card -->
24+
{% capture cardAuthors %}{{ page.authors | join: " and " }}{% endcapture %}
25+
{% capture cardDescription %}Book by {{ cardAuthors }}{% endcapture %}
26+
{% endif %}
27+
1628
<title>{{ fullTitle }}</title>
1729
<meta name="description" content="{{ site.description }}">
1830

@@ -25,19 +37,7 @@
2537
<meta property="og:title" content="{{ fullTitle }}">
2638
<meta property="og:site_name" content="{{ site.title }}">
2739
<meta property="og:description" content="{% if page.description %}{{ page.description | escape }}{% else %}{{ site.description }}{% endif %}">
28-
<meta property="og:image" content="{% if page.image %}{{ page.image | absolute_url }}{% else %}{{ site.default_img | absolute_url }}{% endif %}">
29-
30-
31-
{% if page.path contains 'books' %}
32-
<!-- Twitter card image for books -->
33-
{% capture slugTitle %}{{ page.title | slugify }}{% endcapture %}
34-
{% capture folderPath %}/assets/images/bitcoin/books{% endcapture %}
35-
{% capture cardImageUrl %}{{ folderPath }}/jpg/{{ slugTitle }}.jpg{% endcapture %}
36-
37-
<!-- Description for twitter card -->
38-
{% capture cardAuthors %}{{ page.authors | join: " and " }}{% endcapture %}
39-
{% capture cardDescription %}Book by {{ cardAuthors }}{% endcapture %}
40-
{% endif %}
40+
<meta property="og:image" content="{% if page.image %}{{ page.image | absolute_url }}{% elsif cardImageUrl%}{{ cardImageUrl | absolute_url }}{% else %}{{ site.default_img | absolute_url }}{% endif %}">
4141

4242
<!-- Twitter cards -->
4343
<meta name="twitter:site" content="@{{ site.title }}">

0 commit comments

Comments
 (0)