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 /_plugins/twitter.rb | |
| 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>
Diffstat (limited to '_plugins/twitter.rb')
| -rw-r--r-- | _plugins/twitter.rb | 15 |
1 files changed, 11 insertions, 4 deletions
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 |
