{"id":15134069,"url":"https://github.com/borodean/sharon","last_synced_at":"2025-10-23T09:31:27.405Z","repository":{"id":49000352,"uuid":"80676551","full_name":"borodean/sharon","owner":"borodean","description":"A lightweight and modular social sharing library","archived":false,"fork":false,"pushed_at":"2021-10-15T14:14:36.000Z","size":393,"stargazers_count":19,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T17:38:29.665Z","etag":null,"topics":["buffer","facebook","gmail","google-plus","linkedin","odnoklassniki","pinterest","reddit","share-counts","social-networks","telegram","tumblr","twitter","vkontakte","weibo","xing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/borodean.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-01T23:47:56.000Z","updated_at":"2023-10-30T05:09:03.000Z","dependencies_parsed_at":"2022-09-26T16:31:14.876Z","dependency_job_id":null,"html_url":"https://github.com/borodean/sharon","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borodean%2Fsharon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borodean%2Fsharon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borodean%2Fsharon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borodean%2Fsharon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/borodean","download_url":"https://codeload.github.com/borodean/sharon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237807466,"owners_count":19369596,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["buffer","facebook","gmail","google-plus","linkedin","odnoklassniki","pinterest","reddit","share-counts","social-networks","telegram","tumblr","twitter","vkontakte","weibo","xing"],"created_at":"2024-09-26T05:02:16.516Z","updated_at":"2025-10-23T09:31:22.026Z","avatar_url":"https://github.com/borodean.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Sauce Test Status][saucelabs-badge]][saucelabs]\n\n# ![Sharon][media-sharon]\n\nA lightweight and modular social sharing library:\n\n- a toolkit to build your own share buttons;\n- supports 13 sharing platforms;\n- gzipped size is 1.72 KB;\n- you can cherry-pick which sharing platforms to use to make it even smaller.\n\nHere how it looks when you want Sharon to open a tweet popup:\n\n```js\nsharon.twitter({\n  title: \"One last quarter as defending champs!\",\n  hashtags: [\"SuperBowl\", \"DenverBroncos\"],\n});\n```\n\nOr to get a Facebook share count for your page:\n\n```js\nsharon.facebook.count((err, count) =\u003e {\n  if (err) throw err;\n  console.log(\"Whoa, we have \" + count + \" shares!\");\n});\n```\n\n## Table of contents\n\n- [Setup](#setup)\n  - [CommonJS](#commonjs)\n  - [Browser](#browser)\n- [API](#api)\n  - [Supported sharing platforms](#supported-sharing-platforms)\n  - [sharon._platform_(url = location.href, parameters = { title: document.title })](#sharonplatformurl--locationhref-parameters---title-documenttitle-)\n  - [sharon._platform_.href(url = location.href, parameters = { title: document.title })](#sharonplatformhrefurl--locationhref-parameters---title-documenttitle-)\n  - [sharon._platform_.count(url = location.href, callback)](#sharonplatformcounturl--locationhref-callback)\n  - [Share parameters](#share-parameters)\n- [More examples](#more-examples)\n  - [Poor man\u0026apos;s tweet button](#poor-mans-tweet-button)\n  - [React component](#react-component)\n  - [AngularJS](#angularjs)\n\n## Setup\n\n### CommonJS\n\nInstall Sharon using npm:\n\n```\nnpm install sharon --save\n```\n\nLoad the whole library:\n\n```js\nimport sharon from \"sharon\";\n```\n\nOr cherry-pick platforms for smaller Webpack, Rollup, or Browserify bundles:\n\n```js\nimport facebook from \"sharon/facebook\";\nimport twitter from \"sharon/twitter\";\n```\n\n### Browser\n\n```html\n\u003cscript src=\"dist/sharon.js\"\u003e\u003c/script\u003e\n```\n\nFor the `sharon.js` file, check the `dist` directory of the installed module or directly download it:\n\n- [Production version][download] – 1.72 KB, minified and gzipped\n- [Source map][download-map]\n\n## API\n\n### Supported sharing platforms\n\nEach sharing platform has its endpoint under the Sharon API:\n\n| Sharing platform | Endpoint           | Share count support | Share parameters              |\n| ---------------- | ------------------ | ------------------- | ----------------------------- |\n| Buffer           | `sharon.buffer`    | Yes                 | [Reference][params-buffer]    |\n| Facebook         | `sharon.facebook`  | Yes                 |                               |\n| Gmail            | `sharon.gmail`     |                     |                               |\n| LinkedIn         | `sharon.linkedin`  |                     | [Reference][params-linkedin]  |\n| Odnoklassniki    | `sharon.ok`        | Yes                 |                               |\n| Pinterest        | `sharon.pinterest` | Yes                 | [Reference][params-pinterest] |\n| Reddit           | `sharon.reddit`    | Yes                 | [Reference][params-reddit]    |\n| Telegram         | `sharon.telegram`  |                     |                               |\n| Tumblr           | `sharon.tumblr`    | Yes                 | [Reference][params-tumblr]    |\n| Twitter          | `sharon.twitter`   |                     | [Reference][params-twitter]   |\n| Vkontakte        | `sharon.vk`        | Yes                 | [Reference][params-vk]        |\n| Weibo            | `sharon.weibo`     |                     |                               |\n| XING             | `sharon.xing`      |                     | [Reference][params-xing]      |\n\nThis table also shows which platforms support retrieving share counts and links to the share parameters references.\n\n### sharon._platform_(url = location.href, parameters = { title: document.title })\n\n- `url` \u0026lt;String\u0026gt; The URL to share. Defaults to the current location.\n- `parameters` \u0026lt;Object\u0026gt; [Share parameters](#share-parameters). Default to an object with the title property equal to the current page title.\n\nOpens a share popup.\n\n\u003cdetails\u003e\n\u003csummary\u003eExamples\u003c/summary\u003e\nShare the current page:\n\n```js\nsharon.twitter();\n```\n\nWith a custom title:\n\n```js\nsharon.twitter({ title: \"Check it out\" });\n```\n\nShare example.com:\n\n```js\nsharon.twitter(\"http://example.com\");\n```\n\nShare example.com with a custom title:\n\n```js\nsharon.twitter(\"http://example.com\", { title: \"Check it out\" });\n```\n\n\u003c/details\u003e\n\n### sharon._platform_.href(url = location.href, parameters = { title: document.title })\n\n- `url` \u0026lt;String\u0026gt; The URL to share. Defaults to the current location.\n- `parameters` \u0026lt;Object\u0026gt; [Share parameters](#share-parameters). Default to an object with the title property equal to the current page title.\n- Returns: \u0026lt;String\u0026gt;\n\nReturns a share popup URL.\n\n\u003cdetails\u003e\n\u003csummary\u003eExamples\u003c/summary\u003e\nGet the share popup URL for the current page:\n\n```js\nconst link = sharon.twitter.href();\n```\n\nWith a custom title:\n\n```js\nconst link = sharon.twitter.href({ title: \"Check it out\" });\n```\n\nFor example.com:\n\n```js\nconst link = sharon.twitter.href(\"http://example.com\");\n```\n\nFor example.com with a custom title:\n\n```js\nconst link = sharon.twitter.href(\"http://example.com\", {\n  title: \"Check it out\",\n});\n```\n\n\u003c/details\u003e\n\n### sharon._platform_.count(url = location.href, callback)\n\n- `url` \u0026lt;String\u0026gt; The URL of which to retrive the share count. Defaults to the current location.\n- `callback` \u0026lt;Function(err, count)\u0026gt; A callback function that receives the count.\n\nRetrieves the share count of a URL.\n\n\u003cdetails\u003e\n\u003csummary\u003eExamples\u003c/summary\u003e\nShare count for the current page:\n\n```js\nsharon.facebook.count((err, count) =\u003e {\n  if (err) throw err;\n  console.log(count);\n});\n```\n\nFor example.com:\n\n```js\nsharon.facebook.count(\"http://example.com\", (err, count) =\u003e {\n  if (err) throw err;\n  console.log(count);\n});\n```\n\n\u003c/details\u003e\n\n### Share parameters\n\nWhen using \u003ccode\u003esharon._platform_\u003c/code\u003e or \u003ccode\u003esharon._platform_.href\u003c/code\u003e functions you can specify the share parameters by passing an object as the last argument. They are added to the query parameters of the share popup URL and are specifying additional features:\n\n```js\nsharon.twitter({\n  title: \"One last quarter as defending champs!\",\n  hashtags: [\"SuperBowl\", \"DenverBroncos\"],\n});\n```\n\nThis produces a popup with a predefined title and hashtags:\n\n![Example][media-example]\n\nThe set of features is different for most of the sharing platforms. To find them out, check their documentation, links provided in the [Supported sharing platforms](#supported-sharing-platforms) table.\n\nThere is an inconsistency between different platforms: for instance, Twitter expects the `text` parameter to contain a link title, while Pinterest expects the `description` one. Sharon normalizes this behavior: when you pass a `title` parameter, it is automatically translated into one corresponding to a chosen platform.\n\n## More examples\n\n### Poor man\u0026apos;s tweet button\n\n```html\n\u003cbutton type=\"button\" onclick=\"sharon.twitter()\"\u003eTweet\u003c/button\u003e\n```\n\n### React component\n\n```jsx\nfunction LinkedInShareButton {\n  const [count, setCount] = useState();\n\n  useEffect(() =\u003e {\n    sharon.linkedin.count((err, count) =\u003e {\n      if (err) throw err;\n      setCount(count);\n    });\n  }, []);\n\n  const share = useCallback((event) =\u003e {\n    event.preventDefault();\n    sharon.linkedin();\n  }, []);\n\n  return (\n    \u003ca onClick={share} href={sharon.linkedin.href()}\u003e\n      Share on LinkedIn {count}\n    \u003c/a\u003e\n  );\n}\n```\n\n### AngularJS\n\n```html\n\u003ca ng-click=\"share($event)\" ng-href=\"{{href}}\"\u003eShare on Facebook {{count}}\u003c/a\u003e\n```\n\n```js\n$scope.href = sharon.facebook.href();\n\n$scope.share = (event) =\u003e {\n  event.preventDefault();\n  sharon.facebook();\n};\n\nsharon.facebook.count((err, count) =\u003e {\n  if (err) throw err;\n\n  $scope.$apply(() =\u003e {\n    $scope.count = count;\n  });\n});\n```\n\n![:heart:][media-heart]\n\n[download]: https://github.com/borodean/sharon/releases/download/1.6.0/sharon-1.6.0.min.js\n[download-map]: https://github.com/borodean/sharon/releases/download/1.6.0/sharon-1.6.0.min.js.map\n[media-example]: media/example.png\n[media-heart]: https://cdn.rawgit.com/borodean/sharon/1.6.0/media/heart.svg\n[media-sharon]: https://cdn.rawgit.com/borodean/sharon/1.6.0/media/sharon.svg\n[params-buffer]: https://buffer.com/extras/button\n[params-linkedin]: https://developer.linkedin.com/docs/share-on-linkedin\n[params-pinterest]: https://developers.pinterest.com/docs/widgets/save\n[params-reddit]: https://www.reddit.com/dev/api/#POST_api_submit\n[params-tumblr]: https://www.tumblr.com/docs/en/share_button\n[params-twitter]: https://dev.twitter.com/web/tweet-button/web-intent\n[params-vk]: https://vk.com/dev/share_details\n[params-xing]: https://dev.xing.com/plugins/share_button/docs\n[saucelabs]: https://saucelabs.com/u/borodean-sharon\n[saucelabs-badge]: https://saucelabs.com/browser-matrix/borodean-sharon.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborodean%2Fsharon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborodean%2Fsharon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborodean%2Fsharon/lists"}