Giter Site home page Giter Site logo

avdeev / vanilla-sharing Goto Github PK

View Code? Open in Web Editor NEW
114.0 5.0 22.0 5.78 MB

Small (1.5 KB) simple tool for sharing url, title, description and image to VK, Facebook (Feed, Dialog, Button, Messenger), Reddit, Pinterest, Tumblr, Twitter, VK, OK, Mail.ru, LinkedIn, Whatsapp, Viber, Telegram, Line

Home Page: https://alexey-avdeev.com/vanilla-sharing/

License: MIT License

JavaScript 94.63% TypeScript 5.17% Shell 0.20%
sharing social-buttons vkontakte mailru odnoklassniki facebook twitter messenger linkedin whatsapp-sharing

vanilla-sharing's Introduction

Vanilla Sharing

vanilla-sharing

Small (1.5 KB) simple tool for sharing url, title, description and image to VK, Facebook (Feed, Dialog, Button, Messenger), Twitter, Reddit, Pinterest, Tumblr, VK, OK, Mail.ru, LinkedIn, Whatsapp, Viber, Telegram, Line.

DEMO

Build Status bundlephobia Coverage Status npm npm

Motivation

Adding sharings to a project is digging in the documentation of the corresponding social networks. With this set of small functions, we have already done everything for you. Just take them and use!

Installation

From NPM

npm install --save vanilla-sharing

From unpkg CDN (you can use other)

<script src="https://unpkg.com/vanilla-sharing"></script>

Usage

From NPM

import { fbButton } from 'vanilla-sharing';

fbButton({
  url: 'https://alexey-avdeev.com/vanilla-sharing/',
});

From CDN

VanillaSharing.fbButton({
  url: 'https://alexey-avdeev.com/vanilla-sharing/',
});

API

fbFeed(options)

Share on facebook.com via the Feed dialog

Documentation: https://developers.facebook.com/docs/sharing/reference/feed-dialog

fbFeed({
  url: string,
  redirectUri: string,
  fbAppId: string,
})

You can use getFbFeedUrl(options) for getting URL.

fbShare(options)

Share on facebook.com via the Share dialog

Documentation: https://developers.facebook.com/docs/sharing/reference/share-dialog

fbShare({
  url: string,
  redirectUri: string,
  hashtag: string,
  fbAppId: string,
  quote: string,
})

You can use getFbShareUrl(options) for getting URL.

fbButton(options)

Share on facebook.com using facebook share button

fbButton({
  url: string,
})

You can use getFbButtonUrl(options) for getting URL.

messenger(options)

Share via Facebook Messenger

Share method from Sharing for Messenger.

messenger({
  url: string,
  fbAppId: string,
})

tw(options)

Share on Twitter

tw({
  url: string,
  title: string,
  hashtags: array,
})

You can use getTwUrl(options) for getting URL.

reddit(options)

Share on Reddit

reddit({
  url: string,
  title: string,
})

pinterest(options)

Share on Pinterest

pinterest({
  url: string,
  description: string,
  media: image url string,
})

tumblr(options)

Share on Tumblr

tumblr({
  url: string,
  title: string,
  caption: string,
  tags: array,
})

vk(options)

Share on vk.com

vk({
  url: string,
  title: string,
  description: string,
  image: string,
  isVkParse: boolean,
})

You can use getVkUrl(options) for getting URL.

ok(options)

Share on ok.ru

Like/Share button

ok({
  url: string,
  title: string,
  image: string,
})

You can use getOkUrl(options) for getting URL.

mail(options)

Share on Mail.ru

mail({
  url: string,
  title: string,
  description: string,
  image: string,
})

email(options)

Share via user's email

email({
  to: string,
  url: string,
  title: string,
  description: string,
  subject: string,
})

You can use getEmailUrl(options) for getting URL.

linkedin(options)

Share on LinkedIn

Share method from Share on LinkedIn.

linkedin({
  url: string,
  title: string,
  description: string,
})

whatsapp(options)

Share via Whatsapp

WhatsApp FAQ - Using Click to Chat.

whatsapp({
  url: string,
  title: string,
  phone: string,
})

You can use getWhatsappUrl(options) for getting URL.

viber(options)

Share via Viber

Viber Share Button docs.

viber({
  url: string,
  title: string,
})

You can use getViberUrl(options) for getting URL.

telegram(options)

Share via Telegram

telegram({
  url: string,
  title: string,
})

You can use getTelegramUrl(options) for getting URL.

line(options)

Share via Line

line({
  url: string,
  title: string,
})

vanilla-sharing's People

Contributors

avdeev avatar dependabot[bot] avatar hyoungopb avatar marcusnewton avatar mkhazov avatar nightsurge avatar nonth avatar renovate[bot] avatar stphnnnn avatar willywg avatar zalog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vanilla-sharing's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update actions/checkout action to v4
  • chore(deps): update dependency @size-limit/preset-small-lib to v9
  • chore(deps): update dependency size-limit to v9
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/nodejs.yml
  • actions/checkout v3
  • actions/setup-node v3
npm
package.json
  • @babel/core 7.22.10
  • @babel/eslint-parser 7.22.10
  • @babel/preset-env 7.22.10
  • @faker-js/faker 8.0.2
  • @rollup/plugin-babel 6.0.3
  • @size-limit/preset-small-lib 8.2.6
  • @types/node 18.17.4
  • eslint 8.46.0
  • eslint-config-airbnb-base 15.0.0
  • eslint-import-resolver-webpack 0.13.4
  • eslint-plugin-import 2.28.0
  • husky 8.0.3
  • jest 29.6.2
  • jest-environment-jsdom 29.6.2
  • lint-staged 13.2.3
  • rollup 3.28.0
  • size-limit 8.2.6
  • typescript 5.1.6

  • Check this box to trigger a request for Renovate to run again on this repository

Google+ Removal

Google+ is no longer live and should be removed from this package

Allow get count

Some social networks supports get count of shares. Would be nice provide methods for retrieve this information.

Instagram request.

This has been such a life saver to me. Is there any way to add instagram sharing?
Thanks so much!

Subject line in email sharing

Is it possible to add a subject line to the email sharing?

Not sure how to go about it within your code, but the final structure of your link is:

mailto:?body=

…and this could be enhanced using:

mailto:?subject=supplied_subject_here&body=

…with subject being one of the option parameters.

Option to use the Facebook Share dialog in addition to the Feed dialog.

When sharing from a page, you would need to use the Share dialog. Can we add that option in this library? I am happy to help with a PR if we can agree on an implementation.

We can add as a parameter/flag on the existing facebook dialog function. But that would mean some nasty internals in the function, as the parameters the two dialogs use are different.

Another option is to add a fbShare function (and maybe renaming fb -> fbFeed) to make it more explicit.

Documentation on the dialog:

https://developers.facebook.com/docs/sharing/reference/share-dialog

Add Redit / Tumblr / Others?

Is there any plan to integrate these and other popular sharing sites?

Is the library easy to extend to add custom ones for these? Reddit, at the very least, is critical for my usage.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.