Skip to content

LekoArts/gatsby-source-netlify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gatsby-source-netlify

Source plugin for Netlify's API.

Please Note: This plugin was initially created to deliver data for my dashboard and hence only queries the user and sites. If you need more functionality, I'd be happy to review your PR and merge it into this plugin!

Install

npm install gatsby-source-netlify

How to use

Prerequisites

Go to OAuth applications and create a new access token ("Personal access tokens").

Save the API key in an environment file like:

NETLIFY_KEY=your-access-token-here

gatsby-config.js

Add the plugin and define the API key.

require("dotenv").config();

module.exports = {
  plugins: [
    {
      resolve: "gatsby-source-netlify",
      options: {
        apiKey: process.env.NETLIFY_KEY,
      },
    },
  ],
};

Options

As per netlify/js-client you can also define options when passing the access token, for example:

module.exports = {
  plugins: [
    {
      resolve: "gatsby-source-netlify",
      options: {
        apiKey: process.env.NETLIFY_KEY,
        opts: {
          userAgent: "netlify/js-client",
          scheme: "https",
          host: "api.netlify.com",
          pathPrefix: "/api/v1",
          globalParams: {}, // parameters you want available for every request.
          // Global params are only sent of the open-api spec specifies the provided params.
        },
      },
    },
  ],
};