Sharable
An easily configurable social share libary that uses the social data in your document's head
by default.
1.6kb gzipped
Install
npm i sharable --save
Usage
Add social data to your head
as normal.
Twitter Facebook Pinterest Email Tumblr
const share = // ES5var sharable = var share =
Options
options.selector
Change the attribute you want to bind with Sharable. Default: data-social
.
const share =
locals
You can also pass data to individual links via data attributes to override the default data from the head
.
Tumblr
Supported Networks and Attributes
data-url
data-description
data-hashtags
- comma separated listdata-via
- appendsvia @handle
to the end of the tweet
data-url
Tumblr
data-url
data-title
data-description
data-image
data-url
data-image
data-description
data-url
data-title
API
sharable.update()
Binds any new links and fetches fresh meta data from the head
.
share
sharable.getMeta()
Scrape the document.head
for all social related meta tags. Returns an object with the shape propertyName: propertyValue
i.e. image: 'https://urltomyawesomeimage/image.jpg'
.
share
TODO
- More networks (anyone care to contribute?)
- Tests
MIT License