Skip to content

Commit

Permalink
'summary_large_image' for Twitter card + minor improvements (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwojcik authored May 29, 2023
1 parent 948b4c3 commit e721021
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
6 changes: 3 additions & 3 deletions content/_data/siteConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ module.exports = {
opengraph: {
type: 'website',
// Default image to use when none is specified
image: '/images/share-400x400.jpg',
image: '/images/share-1200x600.jpg',
// Opt-in to automatic generation of OpenGraph images
// If disabled, default images will be used
// If enabled, make sure you _like_ the way they look like
Expand All @@ -127,8 +127,8 @@ module.exports = {
// Default settings for Twitter graph tags
// ---------------------------------------------------------------------------
twitter: {
card: 'summary',
image: '/images/share-400x400.jpg',
card: 'summary_large_image',
image: '/images/share-1200x600.jpg',
},
// ---------------------------------------------------------------------------
// Settings for post tags
Expand Down
12 changes: 10 additions & 2 deletions content/_includes/partials/head.njk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{%- resizedImage image.src, 1200, 630 -%}
{%- endset -%}
{{ openGraphImage | alwaysProductionUrl }}
{% elif opengraph.enableImageGeneration and title %}
{%- elif opengraph.enableImageGeneration and title -%}
{%- set openGraphImage -%}
{{ '/images/share/' }}{{ title | slugify }}{{ '-preview.jpg' }}
{%- endset -%}
Expand All @@ -23,7 +23,7 @@
{%- set pageTitle -%}
{%- if tag -%}
{{ tag.title|capitalizeAllWords }}{% if tag.currentPage >= 2 %} - {{ phrases.page }} {{ tag.currentPage }} {{ phrases.of }} {{ tag.totalPages }}{% endif %} - {{ siteTitle }}
{%- elif title %}
{%- elif title -%}
{{ title | safe }} - {{ siteTitle }}
{%- else -%}
{%- if pagination.pageNumber > 0 -%}
Expand All @@ -44,6 +44,14 @@
{%- endif -%}
{%- endset -%}

{%- set ogCardType -%}
{%- if ogType -%}
{{ ogType }}
{%- else -%}
{{ opengraph.type }}
{%- endif -%}
{%- endset -%}

{% include "partials/head/common.njk" %}
{% include "partials/head/title.njk" %}
{% include "partials/head/styles.njk" %}
Expand Down
2 changes: 1 addition & 1 deletion content/_includes/partials/head/opengraph.njk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<meta property="og:url" content="{{ page.url | alwaysProductionUrl }}">
<meta property="og:type" content="{{ opengraph.type }}">
<meta property="og:type" content="{{ ogCardType }}">
<meta property="og:image" content="{{ ogImage }}">
<meta property="twitter:image" content="{{ ogImage }}">
<meta property="twitter:card" content="{{ twitter.card }}">
3 changes: 2 additions & 1 deletion content/posts/posts.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"tags": ["post"],
"permalink": "{% if customPermalink %}{{ customPermalink }}{% else %}/{{ title | slugify }}/{% endif %}",
"language": "en",
"published": true
"published": true,
"ogType": "article"
}

1 comment on commit e721021

@vercel
Copy link

@vercel vercel bot commented on e721021 May 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.