ashlynbaum / gatsby-source-notion-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gatsby

Notion Source API Gatsby Plugin

gatsby-source-notion-api

This plugin reads a notion table, and renders the contents of the pages and properties in the table.

πŸš€ Quick start

If you already have a Gatsby site, you can use it. Otherwise, you can create a new Gatsby site to test your plugin.

Your directory structure will look similar to this:

/my-gatsby-site
β”œβ”€β”€ gatsby-config.js
└── /src
    └── /pages
        └── /index.js
/my-plugin
β”œβ”€β”€ gatsby-browser.js
β”œβ”€β”€ gatsby-node.js
β”œβ”€β”€ gatsby-ssr.js
β”œβ”€β”€ index.js
β”œβ”€β”€ package.json
└── README.md

With my-gatsby-site being your Gatsby site, and my-plugin being your plugin. You could also include the plugin in your site's plugins folder.

  1. Include the plugin in a Gatsby site

Inside of the gatsby-config.js file of your site (in this case, my-gatsby-site), include the plugin in the plugins array:

module.exports = {
  plugins: [{
    resolve: require.resolve(`../gatsby-source-notion-api`),
    options: {
      tableID: "67873ebd7f5e4b8a968cb69909a889a1",
      notionKey: "secret_Ba6SXUWEUb5iRqfWWkRjR9UgKjnsFkpxED1iwrk0aa1"
    }
  }],
}
}

Replace the tableID and notionKey with your own The line require.resolve('../my-plugin') is what accesses the plugin based on its filepath on your computer, and adds it as a plugin when Gatsby runs.

  1. Verify the plugin was added correctly

The plugin added by the starter implements a single Gatsby API in the gatsby-node that logs a message to the console. When you run gatsby develop or gatsby build in the site that implements your plugin, you should see this message.

You can verify your plugin was added to your site correctly by running gatsby develop for the site.

You should now see a message logged to the console in the preinit phase of the Gatsby build process:

$ gatsby develop
success open and validate gatsby-configs - 0.033s
success load plugins - 0.074s
Loaded gatsby-starter-plugin
success onPreInit - 0.016s
...

πŸŽ“ Learning Gatsby

If you're looking for more guidance on plugins, how they work, or what their role is in the Gatsby ecosystem, check out some of these resources:

About

License:BSD Zero Clause License


Languages

Language:JavaScript 100.0%