npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@raae/gatsby-remark-oembed

v0.3.3

Published

> A GatsbyJS Plugin that transforms oembed links into its corresponding embed code.

Downloads

1,689

Readme

Gatsby Remark oEmbed Plugin

Drop a link to oEmbed content (Twitter, Instagram, YouTube, Vimeo, SoundCloud, CodePen etc.) and see it transform into proper embed html.

 
🚨 gatsby-plugin-mdx support is lacking due to problems with Gatsby Cache in sub-plugins.

 

A message or two from Queen Raae 👑

1-on-1 Emergency Gatsby Call

Are you stuck on a reef in the sharky waters around the Gatsby islands? Check out 1-on-1 Emergency Gatsby Call with Queen Raae to get friendly advice you can put into action immediately from a seasoned Gatsby developer.

Stay updated and get the most out of Gatsby

Learn how to get the most out of Gatsby and stay updated on the plugin by subscribing to daily emails from Queen Raae and Cap'n Ola.

 

A note on oEmbed

oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly.

Learn more by checking out oembed.com.

Links dropped into your markdown content is checked against the oEmbed provider list from oembed.com. If there is a match a call is made to the provider's oEmbed endpoint and the link is swapped for the embed html.

The provider list is downloaded on every build so that oEmbed support stays up to date.

So far these providers are confirmed to be working: CodePen, Flickr, Instagram, Reddit, Twitter, Vimeo, YouTube, SoundCloud.

Twitter, Flickr, Instagram and Reddit requires external javascript to be added to every page. So make sure to exclude the ones you do not need.

Warning: The Instagram oEmbed API requires an access token. You'll need a Facebook Developer account, a Facebook App, and an App Access Token. More information here, or take a look at this tutorial for setting it all up in Gatsby with Environment Variables.

Update: Twitch removed oEmbed support in 2020 when deprecating their v5 API. It seems they are not planning to support oEmbed again. Unfortunately this means Twitch urls are no longer being transformed. Let them know how you feel about this on their forum.

 

How to install

npm install @raae/gatsby-remark-oembed

or

yarn add @raae/gatsby-remark-oembed

Requirements

  • Node version 8 and up.
  • Gatsby version >=2.0.88
  • Gatsby Transformer Remark Plugin >=2.0.0

 

How to use

Configuration

// In your gatsby-config.js
plugins: [
  {
    resolve: `gatsby-transformer-remark`,
    options: {
      plugins: [
        {
          resolve: `@raae/gatsby-remark-oembed`,
          options: {
            // usePrefix defaults to false
            // usePrefix: true is the same as ["oembed"]
            usePrefix: ["oembed", "video"],
            providers: {
              // Important to exclude providers
              // that adds js to the page.
              // If you do not need them.
              exclude: ["Reddit"],
            },
          },
        },
      ],
    },
  },
];

Settings per provider

Many oEmbed providers offer additional options for configure the display of the embed.

For example, for Twitter see Embedded Tweet parameter reference, which describes the additional oEmbed parameters you might want to change for the embed.

// …
{
  resolve: `@raae/gatsby-remark-oembed`,
  options: {
    usePrefix: true,
    providers: {
      include: [
        'Twitter',
        'Instagram',
      ],
      settings: {
        // Ex. Show all Twitter embeds with the dark theme, and disables ad tracking
        Twitter: {
          theme: 'dark',
          dnt: true
        },
        // Ex. Hide all Instagram comments by default, and
        // add a facebook access token
        Instagram: {
           hidecaption: true,
           access_token: 'a-facebook-access-token'
        },
      },
    },
  },
}

Content

With setting usePrefix: true

// In your markdown file

Check it out! I can use oembed links in my markdown.

`oembed: https://twitter.com/raae/status/1045394833001652225`

Its pretty cool :D

`oembed: https://www.instagram.com/p/Bof9WhgBmY2/`

Links must be surrounded by empty lines.

With setting usePrefix: array of prefixes

If you would like to use a prefix other than "oembed" or multiple prefixes you can set usePrefix to an array of custom prefixes. This can be beneficial when converting from other embed plugins.

usePrefix: ["embed", "video", "oembed"]

// In your markdown file

Check it out! I can use the prefix "oembed:"

`oembed: https://twitter.com/raae/status/1045394833001652225`

Or I can use the prefix "embed:" if I like ;)

`embed: https://www.instagram.com/p/Bof9WhgBmY2/`

I can also use "video:" like I did before with `gatsby-remark-video`.

`video: https://vimeo.com/42672205`

usePrefix: true in the section above is the same as usePrefix: ["oembed"].

With setting usePrefix: false

// In your markdown file

Check it out! I can use oembed links in my markdown.

https://twitter.com/raae/status/1045394833001652225

Its pretty cool :D

https://www.instagram.com/p/Bof9WhgBmY2/

Links must be surrounded by empty lines.

Options

| Name | Type | Description | | -------------------- | --------------------------- | ----------------------------------------------------------- | | usePrefix | Boolean / Array of prefixes | See above section on content | | providers.include | Array of provider keys | Only links from providers on this list will be transformed. | | providers.exclude | Array of provider keys | Links from providers on this list will not be transformed. | | providers.settings | Object of provider settings | Optional configuration unique to each provider. |

 

How to contribute

If you would like to contribute with code, check out CONTRIBUTING.md.

Questions, Feedback and Suggestions

Do not be shy!

If you have any questions, feedback or suggestions head on over to discussions.

Bugs

If you find a bug please open an issue and/or create a pull request to fix it.