Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/shobhitsharma/embedo

Embeds third party content to DOM with perks 🧙‍♀️ (7kb gzip / standalone)
https://github.com/shobhitsharma/embedo

embed-content embeds iframe oembed social-media video-embed

Last synced: 9 days ago
JSON representation

Embeds third party content to DOM with perks 🧙‍♀️ (7kb gzip / standalone)

Awesome Lists containing this project

README

        

# embedo [![npm](https://img.shields.io/npm/v/embedo.svg)](https://npmjs.org/package/embedo)

> **Embedo** adds a layer on top of third party embed APIs while ensuring best practices and native guidelines for each component. It takes cares of resizing the container, emitting necessary events and with support for native and external options to be pass along.

### Docs: [Options](https://github.com/shobhitsharma/embedo/wiki/Options) / [API](https://github.com/shobhitsharma/embedo/wiki/API) / [Events](https://github.com/shobhitsharma/embedo/wiki/Events) / [Usage](https://github.com/shobhitsharma/embedo/wiki/Usage) / [Changelog](https://github.com/shobhitsharma/embedo/releases)

### What's currently supported?

- Facebook URLs containing page, post, photos, videos or comments
- Twitter URLs containing user timeline and tweets
- YouTube and Vimeo videos URLs
- Instagram URLs containing posts and videos
- Pinterest URLs containing board, profile and pins
- Google Maps URLs containing cordinates to a location
- Embeds other urls like Github Gists, Soundcloud, Spotify or PDF, MP4, Webm, ... as `iframe`
- Embeds any URL that fulfils HTTP access control (CORS) policy
- Extended plugin support for additonal oembed services
- Supports IE10+ and all modern browsers

---

## Installation

#### NPM / Yarn

```sh
$ npm install embedo --save
$ yarn add embedo
```

#### Bower

```sh
$ bower install embedo
```

#### CDN

Alternatively, import using CDN while updating `version` as per requirements from any script below:

```html

```

## Setup

#### CommonJS / AMD

```js
import Embedo from '/path/to/vendor';

// Initialize Embedo class object
const embedo = new Embedo({
facebook: {
appId: 'my_app_id', // Enable facebook SDK
version: 'v8.0',
access_token: 'app_id_with_client_token_here'
},
twitter: true, // Enable twitter SDK
instagram: { access_token: 'app_id_with_client_token_here' } // Enable instagram SDK
pinterest: true // Enable pinterest SDK,
googlemaps: {
key: 'my_api_key' // Enables google maps API
}
});

// Then call .load() method from anywhere
embedo.load(, , );

// OR Chaining methods and callback
embedo
.load(HTMLElement, URL, options)
.done(Function)
.fail(Function)

// OR storing in a variable
let my_embedo = embedo.load(HTMLElement, URL)
my_embedo.done(Function);
my_embedo.fail(Function);
```

Also, an example can be [found here](https://codepen.io/shobhitsharma/pen/yojJZp).

#### HTML

```html
...


...

new Embedo({
facebook: {
appId: 'my_app_id_here', // Enable facebook SDK
access_token: 'app_id_with_client_token_here', // Client-side token via Graph API
version: 'v8.10'
},
twitter: true, // Enable twitter SDK
instagram: {
access_token: 'app_id_with_client_token_here', // Client-side token via Graph API
}, // Enable instagram SDK
pinterest: true // Enable pinterest SDK,
googlemaps: {
key: 'my_api_key' // Enables google maps API
}
});

```

Also, an example can be [found here](https://github.com/shobhitsharma/embedo/blob/master/test/index.dom.html).