Community Plugin
View plugin on GitHubgastby-source-netlify-cms (Beta)
setting up your gatsby-config.js
Default setup uses the helper functions imported from the plugin.
const config = require(`config.json`); // netlify-cms config file (json format required)
const { createPluginPaths, createPluginOptions } = require('gatsby-source-netlify-cms');
module.exports = {
plugins: [
{
resolve: "gatsby-source-netlify-cms",
options: createPluginOptions(config)
},
...createPluginPaths(config),
]
}Note: The options.types of this plugin must match the options.name targets of the plugin paths being setup for the gatsby-source-filesystem plugin. If you plan to set these up manually, make sure to adhere to this naming convention or this plugin will ignore the nodes during onCreateNode.
Information
This configuration and plugin is going to do the following:
- Create a valid options object for the source plugin using helper
createPluginOptions - Sets up the
gatsby-source-filesystemplugins to the paths of collections using helpercreatePluginPaths - Plugin will resolve the paths for the cms using the config during
onPreBootstrap. If they don’t exist, the plugin will create them. - Plugin creates the schema from the config using Gatsby’s
actions.createTypesduringcreateSchemaCustomizationand using theoptions.typescreated bycreatePluginOptions - Plugin creates the nodes during
onCreateNodeusing the nodes created bygatsby-source-filesystemsetup bycreatePluginPathsand the types configuration created bycreatePluginOptions - All the options and plugins can be configured manually if a more advanced naming of nodes and types is needed.