@fyrepenguin/gatsby-source-youtube
v1.0.2
Published
Sourcing youtube videos
Downloads
5
Readme
@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
][dotenv] which will then expose environment variables. [Read more about dotenv and using environment variables here][envvars]. 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.
- Sign in to YouTube.
- In the top right, click your profile picture and then Settings Settings.
- From the left Menu, select Advanced settings.
- You’ll see your channel’s user and channel IDs.
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,
},
},
],
}