Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
orthagonal committed Aug 9, 2024
1 parent b103cb2 commit c786e28
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ export default class SocialShareButton extends Domodule {
const shareText = this.options.text || SocialShareButton.getMeta('text', 'twi');
const shareTag = this.options.tags || SocialShareButton.getMeta('hashtag', 'twi');
const shareVia = this.options.via || SocialShareButton.getMeta('author', 'twi');
const shareImage = this.options.image || SocialShareButton.getMeta('image', 'twi');

const params = [];

params.push(`url=${encodeURIComponent(this.getShareUrl())}`);
Expand All @@ -150,6 +152,9 @@ export default class SocialShareButton extends Domodule {
params.push(`via=${encodeURIComponent(shareVia)}`);
}

if (shareImage) {
params.push(`media=${encodeURIComponent(shareImage)}`);
}
this.el.href = `${BASE_URLS.twitter}?${params.join('&')}`;
}

Expand Down

0 comments on commit c786e28

Please sign in to comment.