Skip to content

Commit

Permalink
fix(books): properly set og:image for books (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
dergigi authored Aug 28, 2024
1 parent 8712a7c commit 27f2030
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
{{ site.title | escape }}
{% endif %}
{% endcapture %}

{% if page.path contains 'books' %}
<!-- Twitter card image for books -->
{% capture slugTitle %}{{ page.title | slugify }}{% endcapture %}
{% capture folderPath %}/assets/images/bitcoin/books{% endcapture %}
{% capture cardImageUrl %}{{ folderPath }}/jpg/{{ slugTitle }}.jpg{% endcapture %}

<!-- Description for twitter card -->
{% capture cardAuthors %}{{ page.authors | join: " and " }}{% endcapture %}
{% capture cardDescription %}Book by {{ cardAuthors }}{% endcapture %}
{% endif %}

<title>{{ fullTitle }}</title>
<meta name="description" content="{{ site.description }}">

Expand All @@ -25,19 +37,7 @@
<meta property="og:title" content="{{ fullTitle }}">
<meta property="og:site_name" content="{{ site.title }}">
<meta property="og:description" content="{% if page.description %}{{ page.description | escape }}{% else %}{{ site.description }}{% endif %}">
<meta property="og:image" content="{% if page.image %}{{ page.image | absolute_url }}{% else %}{{ site.default_img | absolute_url }}{% endif %}">


{% if page.path contains 'books' %}
<!-- Twitter card image for books -->
{% capture slugTitle %}{{ page.title | slugify }}{% endcapture %}
{% capture folderPath %}/assets/images/bitcoin/books{% endcapture %}
{% capture cardImageUrl %}{{ folderPath }}/jpg/{{ slugTitle }}.jpg{% endcapture %}

<!-- Description for twitter card -->
{% capture cardAuthors %}{{ page.authors | join: " and " }}{% endcapture %}
{% capture cardDescription %}Book by {{ cardAuthors }}{% endcapture %}
{% endif %}
<meta property="og:image" content="{% if page.image %}{{ page.image | absolute_url }}{% elsif cardImageUrl%}{{ cardImageUrl | absolute_url }}{% else %}{{ site.default_img | absolute_url }}{% endif %}">

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

0 comments on commit 27f2030

Please sign in to comment.