Skip to content

Commit 0f02f21

Browse files
committed
Fixes #9 Added support for twitter:title and twitter:description tags
1 parent 981a7f1 commit 0f02f21

5 files changed

Lines changed: 22 additions & 8 deletions

File tree

dist/css/social-share-kit.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/social-share-kit.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Social Share Kit v1.0.1 (http://socialsharekit.com)
2+
* Social Share Kit v1.0.3 (http://socialsharekit.com)
33
* Copyright 2015 Social Share Kit / Kaspars Sprogis.
44
* Licensed under Creative Commons Attribution-NonCommercial 3.0 license:
55
* https://github.com/darklow/social-share-kit/blob/master/LICENSE
@@ -126,8 +126,8 @@ var SocialShareKit = (function () {
126126
var url, dataOpts = getDataOpts(network, el),
127127
shareUrl = getShareUrl(network, el, dataOpts),
128128
shareUrlEnc = encodeURIComponent(shareUrl),
129-
title = typeof dataOpts['title'] !== 'undefined' ? dataOpts['title'] : document.title,
130-
text = typeof dataOpts['text'] !== 'undefined' ? dataOpts['text'] : getMetaContent('description'),
129+
title = typeof dataOpts['title'] !== 'undefined' ? dataOpts['title'] : getTitle(network),
130+
text = typeof dataOpts['text'] !== 'undefined' ? dataOpts['text'] : getText(network),
131131
image = dataOpts['image'], via = dataOpts['via'];
132132
switch (network) {
133133
case 'facebook':
@@ -176,6 +176,20 @@ var SocialShareKit = (function () {
176176
return dataOpts['url'] || window.location.href;
177177
}
178178

179+
function getTitle(network) {
180+
var title;
181+
if (network == 'twitter')
182+
title = getMetaContent('twitter:title');
183+
return title || document.title;
184+
}
185+
186+
function getText(network) {
187+
var text;
188+
if (network == 'twitter')
189+
text = getMetaContent('twitter:description');
190+
return text || getMetaContent('description');
191+
}
192+
179193
function getMetaContent(tagName, attr) {
180194
var text, tag = $('meta[' + (attr ? attr : tagName.indexOf('og:') === 0 ? 'property' : 'name') + '="' + tagName + '"]');
181195
if (tag.length) {

dist/js/social-share-kit.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

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

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

1919
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries for example page --><!--[if lt IE 9]>
2020
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>

less/social-share-kit.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Social Share Kit v1.0.1 (http://socialsharekit.com)
2+
* Social Share Kit v1.0.3 (http://socialsharekit.com)
33
* Copyright 2015 Social Share Kit / Kaspars Sprogis.
44
* Licensed under Creative Commons Attribution-NonCommercial 3.0 license:
55
* https://github.com/darklow/social-share-kit/blob/master/LICENSE

0 commit comments

Comments
 (0)