Skip to content

Commit

Permalink
Merge pull request #1681 from giuseppelt/giuseppelt-og-twitter
Browse files Browse the repository at this point in the history
OpenGraph: added support for twitter image attribute
  • Loading branch information
Xuanwo committed Jan 11, 2016
2 parents 93fcdb5 + 3d2a9a3 commit e4a5204
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/plugins/helper/open_graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ function openGraphHelper(options) {
result += og('og:site_name', siteName);
result += og('og:description', description);

images.map(function(path) {
images = images.map(function(path) {
if (!urlFn.parse(path).host) {
if (path[0] !== '/') path = '/' + path;
return config.url + path;
}

return path;
}).forEach(function(path) {
});
images.forEach(function(path) {
result += og('og:image', path);
});

Expand All @@ -90,6 +91,10 @@ function openGraphHelper(options) {
result += meta('twitter:title', title);
result += meta('twitter:description', description);

if(images.length) {
result += meta('twitter:image', images[0]);
}

if (options.twitter_id) {
var twitterId = options.twitter_id;
if (twitterId[0] !== '@') twitterId = '@' + twitterId;
Expand Down

0 comments on commit e4a5204

Please sign in to comment.