Skip to content

Commit 28f4890

Browse files
committed
Add telegram
1 parent 8bcfb12 commit 28f4890

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

dist/share-buttons.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.

src/share-buttons.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@
1313
var FB_LINK_FORMAT = 'https://www.facebook.com/sharer/sharer.php?u=',
1414
VK_LINK_FORMAT = 'https://vk.com/share.php?url={0}&description={1}. {2}',
1515
TW_LINK_FORMAT = 'https://twitter.com/intent/tweet?url=',
16+
TG_LINK_FORMAT = 'https://telegram.me/share/url?url={0}&text={1}',
1617
MAIL_LINK_FORMAT = 'mailto:?Subject={0}{1}&body={2}{3}',
1718

1819
// from https://wcoder.github.io/notes/string-format-for-string-formating-in-javascript
1920
stringFormat = function (str, args) {
2021
return str.replace(/\{(\d+)\}/g, function (m, n) {
2122
return args[n] || m;
2223
});
24+
},
25+
26+
mergeForTitle = function (texts) {
27+
return texts.join(' - ');
2328
};
2429

2530
/**
@@ -130,6 +135,15 @@
130135
this.popupCenter(TW_LINK_FORMAT + url + text, titleDef);
131136
break;
132137

138+
case 'tg':
139+
this.popupCenter(
140+
stringFormat(TG_LINK_FORMAT, [
141+
url,
142+
mergeForTitle([title, desc])
143+
]),
144+
titleDef);
145+
break;
146+
133147
case 'mail':
134148
if (title.length > 0 && desc.length > 0) {
135149
text = title + ' - ' + desc;

0 commit comments

Comments
 (0)