Skip to content

Commit 9d5a473

Browse files
authored
Merge pull request #79 from valentinoli/patch-2
Add hashtag option to Facebook
2 parents 84f8256 + a3abe17 commit 9d5a473

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ navigator.share({
4646
```
4747

4848
But in this case, you can also pass your `Facebook App Id` to enable sharing with **messenger**.
49-
Also, you can pass in a list of hashtags to be used when sharing with twitter.
49+
Also, you can pass in a list of hashtags to be used when sharing with twitter or facebook. Only one hashtag can be shared with facebook so the first one in the list will be shared.
5050

5151
```js
5252
navigator.share({

src/share.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ navigator.share = navigator.share || (function () {
226226
reject('Invalid Params');
227227
}
228228

229-
const { title, url, fbId, hashtags } = data;
229+
const { title, url, fbId, hashtags, hashtag } = data;
230230
const configs = {
231231
...{
232232
copy: true,
@@ -570,7 +570,8 @@ navigator.share = navigator.share || (function () {
570570
window.open(
571571
'https://www.facebook.com/sharer/sharer.php?' +
572572
'u=' + encodeURIComponent(url) +
573-
'&quote=' + encodeURIComponent(text)
573+
'&quote=' + encodeURIComponent(text) +
574+
'&hashtag=' + (hashtag || hashtags || '')
574575
)
575576
break;
576577
}

0 commit comments

Comments
 (0)