trevordmiller / social-media-links

Generate social media sharing links on the client or server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

social-media-links

Build Status

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,anothercoolhashtag

API

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:
    • email
    • twitter
    • pinterest
    • facebook
    • googlePlus
    • linkedIn
    • buffer
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: array of strings
  • Default: ['']

Tests

$ npm test


Contributing

PRs are welcome! Just follow these steps:

  1. Clone
  2. npm install
  3. Follow code style in project
  4. npm run lint
  5. npm test

License

MIT © Trevor D. Miller

About

Generate social media sharing links on the client or server

License:MIT License


Languages

Language:JavaScript 100.0%