1.0.2 • Published 11 years ago
social-media-links v1.0.2
social-media-links
Generate social media sharing links on the client or server
Install
$ npm install social-media-links --save
Example
import socialMediaLinks from 'social-media-links';
let socialData = {
account: 'twitter',
url: 'https://some-cool-url.com',
title: 'This is a sweet title',
via: 'coolaccount44',
hashtags: [
'coolhashtag',
'anothercoolhashtag'
]
};
let twitterLink = socialMediaLinks.create(socialData);
//=> https://twitter.com/share?url=https://some-cool-url.com&text=This is a sweet title&via=coolaccount44&hashtags=coolhashtag,anothercoolhashtagAPI
socialMediaLinks.create(options)
Generate a link for sharing on social media.
- Returns:
string
options
account
Social media account type for the link.
- Type:
string - Default:
'email' - Options:
emailtwitterpinterestfacebookgooglePluslinkedInbuffer
url
Url for the link.
- Type:
string - Default:
''
title (optional)
Title for the link.
- Type:
string - Default:
''
img (optional)
Image thumbnail for the link.
- Type:
string - Default:
''
via (optional)
Username of content author. Don't include the @ as this will be added automatically.
- Type:
string - Default:
''
hashtags (optional)
List of hashtags for the link. Don't include the # as this will be added automatically.
- Type:
arrayofstrings - Default:
['']
Tests
$ npm test
Contributing
PRs are welcome! Just follow these steps:
- Clone
npm install- Follow code style in project
npm run lintnpm test
License
MIT © Trevor D. Miller