Skip to content

Commit

Permalink
Fixes #9 Added support for twitter:title and twitter:description tags
Browse files Browse the repository at this point in the history
  • Loading branch information
darklow committed Apr 3, 2015
1 parent 981a7f1 commit 0f02f21
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/css/social-share-kit.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions dist/js/social-share-kit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Social Share Kit v1.0.1 (http://socialsharekit.com)
* Social Share Kit v1.0.3 (http://socialsharekit.com)
* Copyright 2015 Social Share Kit / Kaspars Sprogis.
* Licensed under Creative Commons Attribution-NonCommercial 3.0 license:
* https://github.com/darklow/social-share-kit/blob/master/LICENSE
Expand Down Expand Up @@ -126,8 +126,8 @@ var SocialShareKit = (function () {
var url, dataOpts = getDataOpts(network, el),
shareUrl = getShareUrl(network, el, dataOpts),
shareUrlEnc = encodeURIComponent(shareUrl),
title = typeof dataOpts['title'] !== 'undefined' ? dataOpts['title'] : document.title,
text = typeof dataOpts['text'] !== 'undefined' ? dataOpts['text'] : getMetaContent('description'),
title = typeof dataOpts['title'] !== 'undefined' ? dataOpts['title'] : getTitle(network),
text = typeof dataOpts['text'] !== 'undefined' ? dataOpts['text'] : getText(network),
image = dataOpts['image'], via = dataOpts['via'];
switch (network) {
case 'facebook':
Expand Down Expand Up @@ -176,6 +176,20 @@ var SocialShareKit = (function () {
return dataOpts['url'] || window.location.href;
}

function getTitle(network) {
var title;
if (network == 'twitter')
title = getMetaContent('twitter:title');
return title || document.title;
}

function getText(network) {
var text;
if (network == 'twitter')
text = getMetaContent('twitter:description');
return text || getMetaContent('description');
}

function getMetaContent(tagName, attr) {
var text, tag = $('meta[' + (attr ? attr : tagName.indexOf('og:') === 0 ? 'property' : 'name') + '="' + tagName + '"]');
if (tag.length) {
Expand Down
2 changes: 1 addition & 1 deletion dist/js/social-share-kit.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

<!-- Bootstrap for examples page -->
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="docs.css?v=v1.0.1">
<link rel="stylesheet" href="docs.css?v=v1.0.3">

<!-- Social Share Kit CSS -->
<link rel="stylesheet" href="../dist/css/social-share-kit.css?v=v1.0.1">
<link rel="stylesheet" href="../dist/css/social-share-kit.css?v=v1.0.3">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries for example page --><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion less/social-share-kit.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Social Share Kit v1.0.1 (http://socialsharekit.com)
* Social Share Kit v1.0.3 (http://socialsharekit.com)
* Copyright 2015 Social Share Kit / Kaspars Sprogis.
* Licensed under Creative Commons Attribution-NonCommercial 3.0 license:
* https://github.com/darklow/social-share-kit/blob/master/LICENSE
Expand Down

0 comments on commit 0f02f21

Please sign in to comment.