-
-
Notifications
You must be signed in to change notification settings - Fork 444
Expand file tree
/
Copy pathTumblrShareButton.tsx
More file actions
69 lines (62 loc) · 1.47 KB
/
TumblrShareButton.tsx
File metadata and controls
69 lines (62 loc) · 1.47 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { forwardRef } from 'react';
import assert from './utils/assert';
import objectToGetParams from './utils/objectToGetParams';
import ShareButton, { type ShareButtonProps } from './ShareButton';
function tumblrLink(
url: string,
{
title,
caption,
tags,
posttype,
content,
}: {
title?: string;
caption?: string;
tags?: string;
posttype?: 'link' | string;
content?: string;
},
) {
assert(url, 'tumblr.url');
return (
'https://www.tumblr.com/widgets/share/tool' +
objectToGetParams({
canonicalUrl: url,
title,
caption,
tags,
posttype,
content,
})
);
}
type Options = {
title?: string;
caption?: string;
posttype?: 'link' | 'text' | 'quote' | 'photo' | 'chat' | 'video' | string;
content?: string;
};
type TumblrShareButtonProps = Omit<ShareButtonProps<Options & { tags: string }>, 'title'> &
Options & { tags?: string[] };
const TumblrShareButton = forwardRef<HTMLButtonElement, TumblrShareButtonProps>(
({ caption, posttype, tags, title, content, ...props }, ref) => (
<ShareButton
{...props}
forwardedRef={ref}
networkName="tumblr"
networkLink={tumblrLink}
opts={{
title,
tags: (tags || []).join(','),
caption,
posttype: posttype || 'link',
content,
}}
windowHeight={460}
windowWidth={660}
/>
),
);
TumblrShareButton.displayName = 'TumblrShareButton';
export default TumblrShareButton;