npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sharable

v1.0.1

Published

An easily configurable social share libary that uses the social data in your document's head by default.

Downloads

38

Readme

Sharable npm

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.

<html>
<head>
  <meta prefix="og: http://ogp.me/ns#" property="og:description" content="A javascript sandbox, by Eric Bailey."/>
  <meta prefix="og: http://ogp.me/ns#" property="og:site_name" content="Sandbox"/>
  <meta prefix="og: http://ogp.me/ns#" property="og:title" content="Sandbox" />
  <meta prefix="og: http://ogp.me/ns#" property="og:image" content="https://s3.amazonaws.com/StartupStockPhotos/uploads/20160503/3.jpg" />
  <meta prefix="og: http://ogp.me/ns#" property="og:url" content="http://estrattonbailey.com" />

  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:title" content="Sandbox">
  <meta name="twitter:description" content="A javascript sandbox, by Eric Bailey.">
  <meta name="twitter:image" content="https://s3.amazonaws.com/StartupStockPhotos/uploads/20160503/3.jpg">
</head>
<body>

  <a href="#0" data-social="twitter">Twitter</a>
  <a href="#0" data-social="facebook">Facebook</a>
  <a href="#0" data-social="pinterest">Pinterest</a>
  <a href="#0" data-social="email">Email</a>
  <a href="#0" data-social="tumblr">Tumblr</a>

</body>
</html>
import sharable from 'sharable'

const share = sharable()

// ES5
var sharable = require('sharable/browser')
var share = sharable()

Options

options.selector

Change the attribute you want to bind with Sharable. Default: data-social.

const share = sharable({
  selector: 'data-social-link'
})

locals

You can also pass data to individual links via data attributes to override the default data from the head.

<a href="#0"
  data-social="tumblr"
  data-description="Description for the tumblr post."
  data-url="http://estrattonbailey.tumblr.com"
  >
  Tumblr
</a>

Supported Networks and Attributes

Twitter

  • data-url
  • data-description
  • data-hashtags - comma separated list
  • data-via - appends via @handle to the end of the tweet

Facebook

  • data-url

Tumblr

  • data-url
  • data-title
  • data-description
  • data-image

Pinterest

  • data-url
  • data-image
  • data-description

Email

  • data-url
  • data-title

API

sharable.update()

Binds any new links and fetches fresh meta data from the head.

share.update()

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.getMeta()

TODO

  1. More networks (anyone care to contribute?)
  2. Tests

MIT License