diff options
| -rw-r--r-- | _layouts/default.html | 4 | ||||
| -rw-r--r-- | _plugins/twitter.rb | 15 |
2 files changed, 14 insertions, 5 deletions
diff --git a/_layouts/default.html b/_layouts/default.html index 2b452db..9ae7643 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -32,9 +32,11 @@ <meta name="description" content="{{ description }}"> {% comment %}<!-- Twitter stuff -->{% endcomment %} - <meta name="twitter:card" content="summary" /> + <meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:site" content="@miquelssola" /> <meta name="twitter:creator" content="@miquelssola" /> + <meta name="twitter:description" content="{{ description }}" /> + <meta name="twitter:title" content="{{ title }}" /> {% comment %}<!-- OpenGraph protocol -->{% endcomment %} {% if site.lang == "ca" %} diff --git a/_plugins/twitter.rb b/_plugins/twitter.rb index bc4c99b..2c9cbfd 100644 --- a/_plugins/twitter.rb +++ b/_plugins/twitter.rb @@ -24,7 +24,8 @@ module Jekyll def render(context) img = normalize(context["raw_title"]) + ".png" path = image_exists?(img) ? "/images/posts/#{img}" : DEFAULT_PATH - render_meta("og:image", "http://jo.mssola.com#{path}") + render_meta("og:image", "http://jo.mssola.com#{path}") + + render_meta("twitter:image", "http://jo.mssola.com#{path}", name: true) end protected @@ -42,9 +43,15 @@ module Jekyll str.gsub(/\s/, "-").downcase end - # Render an HTML meta tag with the given property and content attributes. - def render_meta(property, content) - "<meta property=\"#{property}\" content=\"#{content}\" />" + # Render an HTML meta tag with the given property and content + # attributes. You may optionally pass a `name` argument. When true, it will + # use "name" instead of "property". Defaults to nil. + def render_meta(property, content, name: nil) + if name + "<meta name=\"#{property}\" content=\"#{content}\" />" + else + "<meta property=\"#{property}\" content=\"#{content}\" />" + end end end end |
