Coder Social home page Coder Social logo

gatsby-remark-embedder's Introduction

gatsby-remark-embedder logo

gatsby-remark-embedder

Gatsby Remark plugin to embed well known services by their URL.


Build Status Code Coverage version downloads MIT License

All Contributors PRs Welcome Code of Conduct

The problem

Trying to embed well known services (like CodePen, CodeSandbox, Slides, SoundCloud, Spotify, Twitter or YouTube) into your Gatsby website can be hard, since you have to know how this needs to be done for all of these different services.

This solution

gatsby-remark-embedder tries to solve this problem for you by letting you just copy-paste the link to the pen/player/sandbox/tweet/video you want to embed right from within your browser onto a separate line (surrounded by empty lines) and replace it with the proper embed-code.

Table of Contents

Installation

This module is distributed via npm which is bundled with node and should be installed as one of your project's dependencies:

npm install --save gatsby-remark-embedder

This library has peerDependencies listings for gatsby.

Usage

// In your gatsby-config.js

plugins: [
  {
    resolve: `gatsby-transformer-remark`,
    options: {
      plugins: [`gatsby-remark-embedder`],
    },
  },
];

Supported services

CodePen

Usage

https://codepen.io/team/codepen/pen/PNaGbb

Result

<iframe
  src="https://codepen.io/team/codepen/embed/preview/PNaGbb"
  style="width:100%; height:300px;"
></iframe>

CodeSandbox

Usage

https://codesandbox.io/s/ynn88nx9x?view=split

Result

<iframe
  src="https://codesandbox.io/embed/ynn88nx9x?view=split"
  style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;"
  allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
  sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
></iframe>

Slides

Usage

https://slides.com/kentcdodds/oss-we-want

Result

<iframe
  src="https://slides.com/kentcdodds/oss-we-want/embed"
  width="576"
  height="420"
  scrolling="no"
  frameborder="0"
  webkitallowfullscreen
  mozallowfullscreen
  allowfullscreen
></iframe>

SoundCloud

Usage

https://soundcloud.com/clemenswenners/africa

Result

<iframe
  width="100%"
  height="300"
  scrolling="no"
  frameborder="no"
  src=https://w.soundcloud.com/player?url=https://soundcloud.com/clemenswenners/africa&color=ff5500&auto_play=false&hide_related=true&show_comments=true&show_user=true&show_reposts=false&show_teaser=false&visual=true
></iframe>

Spotify

Usage

https://open.spotify.com/track/0It2bnTdLl2vyymzOkBI3L

Result

<iframe
  src="https://open.spotify.com/embed/track/0It2bnTdLl2vyymzOkBI3L"
  width="100%"
  height="380"
  frameborder="0"
  allowtransparency="true"
  allow="encrypted-media"
></iframe>

Twitter

The returned HTML snippet from the Twitter transformer will only be automatically recognized as an Embedded Tweet when Twitter's widget JavaScript is included on the page.
Since the Twitter transformer doesn't include this JavaScript (because we don't want to include it multiple times on a page when having multiple embeds), you have to include it yourself. The recommended way of including it is by using gatsby-plugin-twitter.

Usage

https://twitter.com/MichaelDeBoey93/status/1152991421789548546

Result

<blockquote class="twitter-tweet" data-dnt="true">
  <p lang="en" dir="ltr" class="css-yw8fqx e11rucy10">
    Happy to announce I just published the first gatsby-remark-embedder πŸŽ‰πŸŽ‰πŸŽ‰
    <br />
    <br />
    This first version is an extract of
    <a href="https://twitter.com/kentcdodds">@kentcdodds</a>' personal website
    remark-embedder plugin, but I'm planning on adding extra services then
    <a href="https://twitter.com/codesandbox">@codesandbox</a>,<a
      href="https://twitter.com/Twitter"
    >
      @Twitter
    </a>
    &amp; <a href="https://twitter.com/YouTube">@YouTube</a> too.
    <a href="https://t.co/M4PA9aFZdG">https://t.co/M4PA9aFZdG</a>
  </p>
  β€” MichaΓ«l De Boey (@MichaelDeBoey93)
  <a href="https://twitter.com/MichaelDeBoey93/status/1152991421789548546">
    July 21, 2019
  </a>
</blockquote>

YouTube

The YouTube transformer (currently) only supports videos in the following formats:

  • Full url (https://youtube.com/watch?v=dQw4w9WgXcQ)
  • Short url (https://youtu.be/dQw4w9WgXcQ)

Usage

https://youtu.be/dQw4w9WgXcQ

Result

<iframe
  width="100%"
  height="315"
  src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?rel=0"
  frameborder="0"
  allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
  allowfullscreen
></iframe>

Inspiration

This whole library was extracted out of Kent C. Dodds' personal website.

The intention is to make this available to be used independently.

Issues

Looking to contribute? Look for the Good First Issue label.

πŸ› Bugs

Please file an issue for bugs, missing documentation, or unexpected behavior.

See Bugs

πŸ’‘ Feature Requests

Please file an issue to suggest new features. Vote on feature requests by adding a πŸ‘. This helps maintainers prioritize what to work on.

See Feature Requests

Contributors

Thanks goes to these people (emoji key):

Kent C. Dodds
Kent C. Dodds

πŸ’» πŸ“– πŸ€” πŸš‡ ⚠️
MichaΓ«l De Boey
MichaΓ«l De Boey

πŸ› πŸ’» πŸ“– ⚠️
Kornel Dubieniecki
Kornel Dubieniecki

πŸ›
Nick Nish
Nick Nish

πŸ’» ⚠️
Caneco
Caneco

🎨
Anurag Hazra
Anurag Hazra

πŸ› πŸ’» ⚠️
Yash Joshi
Yash Joshi

πŸ’» ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

LICENSE

MIT

gatsby-remark-embedder's People

Contributors

allcontributors[bot] avatar anuraghazra avatar caneco avatar dependabot-preview[bot] avatar imgbot[bot] avatar jyash97 avatar michaeldeboey avatar nicknish avatar

Watchers

 avatar

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.