1.0.2 • Published 5 years ago

@fyrepenguin/gatsby-source-youtube v1.0.2

Weekly downloads
3
License
MIT
Repository
-
Last release
5 years ago

@fyrepenguin/gatsby-source-youtube

Source from Youtube API (v3) in Gatsby.


Install

npm install --save @fyrepenguin/gatsby-source-youtube

How to use

Prerequisites

First, you need a way to pass environment variables to the build process, so secrets and other secured data aren't committed to source control. I recommend using dotenv which will then expose environment variables. Read more about dotenv and using environment variables here. Then you can use these environment variables and configure your plugin.

You'll need an API Key from google and Channel ID from youtube channel.

  1. Create your API Key
  2. Get your Channel ID

    1. Sign in to YouTube.
    2. In the top right, click your profile picture and then Settings Settings.
    3. From the left Menu, select Advanced settings.
    4. You’ll see your channel’s user and channel IDs.
  3. Save both to your environment variable file

It should look something like this:

API_KEY=your-api-key-here
CHANNEL_ID=your-session-id-here

gatsby-config

The plugin sets some defaults for the endpoints and options. Hence you can use it only with the two mandatory entries apiKey and channelId.

module.exports = {
  plugins: [
    {
      resolve: '@fyrepenguin/gatsby-source-youtube',
      options: {
        // apiKey and channelId are mandatory
        apiKey: process.env.API_KEY,
        channelId: process.env.CHANNEL_ID,
      },
    },
  ],
}