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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ import {
| via | string | | | ❌ |
| hashtags | array | | | ❌ |
| related | array | | | ❌ |
| isMobile | boolean | false | Supports twitter share for mobile if set to `true` | ❌ |
| windowWidth | number | 550 | Opened window width. | ❌ |
| windowHeight | number | 400 | Opened window height. | ❌ |
| blankTarget | boolean | false | Open share window in a new tab if set to `true`. | ❌ |
Expand Down Expand Up @@ -1089,4 +1090,4 @@ export default class Sticky extends Component<Props> {
}
}

====================== -->
====================== -->
15 changes: 13 additions & 2 deletions src/components/buttons/TwitterShareButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ function twitterLink(
via,
hashtags = [],
related = [],
}: { title?: string; via?: string; hashtags?: string[]; related?: string[] },
isMobile = false,
}: {
title?: string;
via?: string;
hashtags?: string[];
related?: string[];
isMobile?: boolean;
},
) {
return (
'https://twitter.com/intent/tweet' +
(isMobile
? 'https://mobile.twitter.com/intent/tweet'
: 'https://twitter.com/intent/tweet') +
transformObjectToParams({
url,
text: title,
Expand All @@ -27,6 +36,7 @@ const TwitterShareButton = createShareButton<{
via?: string;
hashtags?: string[];
related?: string[];
isMobile?: boolean;
}>(
'twitter',
twitterLink,
Expand All @@ -35,6 +45,7 @@ const TwitterShareButton = createShareButton<{
title: props.title,
via: props.via,
related: props.related,
isMobile: props.isMobile,
}),
{
windowWidth: 550,
Expand Down