1.0.2 • Published 5 years ago
@fyrepenguin/gatsby-source-youtube
Licence
MIT
Version
1.0.2
Deps
3
Size
10 kB
Vulns
0
Weekly
0
@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,
},
},
],
}