Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wp-pwa/share
Share utilities for » Frontity themes
https://github.com/wp-pwa/share
Last synced: 2 days ago
JSON representation
Share utilities for » Frontity themes
- Host: GitHub
- URL: https://github.com/wp-pwa/share
- Owner: wp-pwa
- License: mit
- Created: 2018-06-06T09:39:02.000Z (over 6 years ago)
- Default Branch: dev
- Last Pushed: 2018-10-31T09:04:18.000Z (about 6 years ago)
- Last Synced: 2024-11-14T01:03:51.597Z (7 days ago)
- Language: JavaScript
- Homepage: https://frontity.com
- Size: 884 KB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @frontity/share
Share utilities for the [:fast_forward: Frontity](https://github.com/wp-pwa/wp-pwa) platform.
[![npm version](https://badge.fury.io/js/%40frontity%2Fshare.svg)](https://badge.fury.io/js/%40frontity%2Fshare) [![Build Status](https://travis-ci.org/frontity/share.svg?branch=master)](https://travis-ci.org/frontity/share)
## Usage
Install @frontity/share using [`npm`](https://www.npmjs.com/):
```bash
npm install @frontity/share
```Then, import and use it in your [mobx-state-tree](https://github.com/mobxjs/mobx-state-tree) store:
```javascript
import { types } from 'mobx-state-tree';
import Share from '@frontity/share';const myStore = types.model('MyStore')
.props({
share: types.optional(Share, {}),
})
.create({});...
await myStore.share.facebook.requestCount({ type: 'post', id: 60 });
// Returns the share count of the item with type 'post' and id '60'.
myStore.share.facebook.count({ type: 'post', id: 60 });// Returns the url for sharing the link of the item with type 'post' and id '60'.
myStore.share.facebook.url({ type: 'post', id: 60 });```
## API
### Share
* `share.networks` - Returns the list of all supported networks.### Networks
#### counts
Permitted values for `network` are `all`, `facebook`, `googlePlus` and `pinterest`.
* `share[network].count({ type, id })`
* `share[network].requestCount({ type, id })`#### urls
* `share.facebook.url({ type, id, quote, hashtag })`
* `share.googlePlus.url({ type, id })`
* `share.linkedin.url({ type, id, title, summary })`
* `share.twitter.url({ type, id, text, via, hashtags })`
* `share.whatsapp.url({ type, id, text })`
* `share.telegram.url({ type, id, text })`
* `share.email.url({ type, id, subject, body })`
* `share.pinterest.url({ type, id, media, description })`## Contribute
Thank you for thinking about contributing to a Frontity project!
Please take a look at [this repo](https://github.com/frontity/contribute) to know how to do so.