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 🙏

© 2025 – Pkg Stats / Ryan Hefner

share2

v0.0.6

Published

一键分享到微博、QQ空间、QQ好友、微信、腾讯微博、豆瓣、Facebook、Twitter、Linkedin、Google+、点点等,仅46k,包含样式与图标,无需繁杂的引入

Readme

Share.js

自动生成分享组件,包括(微博、QQ空间、QQ好友、微信、腾讯微博、豆瓣、Facebook、Twitter、Linkedin、Google+、点点)等网站

安装

  1. 使用 npm

    npm install share2
  2. 手动下载或者 git clone 本项目。

使用

HTML:

<div class="share"></div>

<!--  引入js -->
<script src="dist/js/Share.js"></script>

// 当你使用类名为 `.custom-share` 时不需要手动初始化

自定义配置

所有配置可选, 通常默认就满足需求:

可用的配置有:


url                 : '', // 网址,默认使用 window.location.href
source              : '', // 来源(QQ空间会用到), 默认读取head标签:<meta name="site" content="http://overtrue" />
title               : '', // 标题,默认读取 document.title 或者 <meta name="title" content="share.js" />
origin              : '', // 分享 @ 相关 twitter 账号
description         : '', // 描述, 默认读取head标签:<meta name="description" content="PHP弱类型的实现原理分析" />
image               : '', // 图片, 默认取网页中第一个img标签
sites               : ['qzone', 'qq', 'weibo','wechat', 'douban'], // 启用的站点(此顺序代表最终渲染的顺序)
disabled            : ['google', 'facebook', 'twitter'], // 禁用的站点(即使sites参数指定的站点,这里也可以禁用)
initialized         : false // 自定义初始化
wechatQrcodeTitle   : '微信扫一扫:分享', // 微信二维码提示文字
wechatQrcodeHelper  : '<p>微信里点“发现”,扫一下</p><p>二维码便可将本文分享至朋友圈。</p>'
wechatQrcodePosition: 'top', // 二维码展示方向 仅支持top bottom

示例代码:

var $config = {
    title               : '234',
    description         : '123',
    wechatQrcodeTitle   : "微信扫一扫:分享", // 微信二维码提示文字
    wechatQrcodeHelper  : '<p>微信里点“发现”,扫一下</p><p>二维码便可将本文分享至朋友圈。</p>',
};

share('.social-share-cs', $config);

自定义初始化

如果不喜欢默认的样式、图标,可以尝试使用自定义初始化

<div class="share">
    <!-- 保证存在与sites参数列表相同类名的a标签 -->
    <a class="google" href="">google</a>
    <a class="twitter" href="">twitter</a>
</div>
var share = new Share('.share', {
    sites: ['google', 'twitter'],
    initialized: true
});