Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/spicy-ghosts-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-share": minor
---

Add content field to TumblrShareButton
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ Optional props:
- `tags` (`string[]`): Tags to attach to the post.
- `caption` (`string`): Description shown with the shared page.
- `posttype` (`string`, default `"link"`): Tumblr post type.
- `content` (`string`): The content for some post types. See [Tumblr's documentation](https://help.tumblr.com/knowledge-base/share-button-documentation/) for details.

```jsx
import { TumblrShareButton, TumblrIcon } from "react-share";
Expand Down
16 changes: 13 additions & 3 deletions src/TumblrShareButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ function tumblrLink(
caption,
tags,
posttype,
}: { title?: string; caption?: string; tags?: string; posttype?: 'link' | string },
content,
}: {
title?: string;
caption?: string;
tags?: string;
posttype?: 'link' | string;
content?: string;
},
) {
assert(url, 'tumblr.url');

Expand All @@ -22,21 +29,23 @@ function tumblrLink(
caption,
tags,
posttype,
content,
})
);
}

type Options = {
title?: string;
caption?: string;
posttype?: 'link' | 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, ...props }, ref) => (
({ caption, posttype, tags, title, content, ...props }, ref) => (
<ShareButton
{...props}
forwardedRef={ref}
Expand All @@ -47,6 +56,7 @@ const TumblrShareButton = forwardRef<HTMLButtonElement, TumblrShareButtonProps>(
tags: (tags || []).join(','),
caption,
posttype: posttype || 'link',
content,
}}
windowHeight={460}
windowWidth={660}
Expand Down
Loading