diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2019-10-20 21:09:55 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <msabate@suse.com> | 2019-10-20 21:09:55 +0200 |
| commit | 86e58a3fc98fc69a133e621b713773d2b8a5efe9 (patch) | |
| tree | 0376539207be3911bf93ced4bebbe21618ebb539 | |
| parent | 420e822c8f52370bc063c8ab9df417a9a3d211bf (diff) | |
| download | jo.mssola.com-86e58a3fc98fc69a133e621b713773d2b8a5efe9.tar.gz jo.mssola.com-86e58a3fc98fc69a133e621b713773d2b8a5efe9.zip | |
Fixed some meta attributes for Twitter
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
| -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 |
