forked from nygardk/react-share
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTumblrShareButton.ts
52 lines (47 loc) · 1013 Bytes
/
TumblrShareButton.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import assert from './utils/assert';
import objectToGetParams from './utils/objectToGetParams';
import createShareButton from './hocs/createShareButton';
function tumblrLink(
url: string,
{
title,
caption,
tags,
posttype,
}: { title?: string; caption?: string; tags?: string; posttype?: 'link' | string },
) {
assert(url, 'tumblr.url');
return (
'https://www.tumblr.com/widgets/share/tool' +
objectToGetParams({
canonicalUrl: url,
title,
caption,
tags,
posttype,
})
);
}
type Options = {
title?: string;
caption?: string;
posttype?: 'link' | string;
};
const TumblrShareButton = createShareButton<
Options & { tags?: string[] },
Options & { tags: string }
>(
'tumblr',
tumblrLink,
props => ({
title: props.title,
tags: (props.tags || []).join(','),
caption: props.caption,
posttype: props.posttype || 'link',
}),
{
windowWidth: 660,
windowHeight: 460,
},
);
export default TumblrShareButton;