This plugin reads a notion table, and renders the contents of the pages and properties in the table.
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.
- 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.
- 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
...
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:
- The Creating Plugins section of the docs has information on authoring and maintaining plugins yourself.
- The conceptual guide on Plugins, Themes, and Starters compares and contrasts plugins with other pieces of the Gatsby ecosystem. It can also help you decide what to choose between a plugin, starter, or theme.
- The Gatsby plugin library has over 1750 official as well as community developed plugins that can get you up and running faster and borrow ideas from.