From 86e58a3fc98fc69a133e621b713773d2b8a5efe9 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Sun, 20 Oct 2019 21:09:55 +0200 Subject: Fixed some meta attributes for Twitter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- _layouts/default.html | 4 +++- _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 @@ {% comment %}{% endcomment %} - + + + {% comment %}{% 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) - "" + # 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 + "" + else + "" + end end end end -- cgit v1.2.3