Page Creation
A page is created by calling the createPage action. There are three main side effects that occur when a page is created.
- The
pages
Redux namespace is updated - The
components
Redux namespace is updated onCreatePage
API is executed
Update pages Redux namespace
The pages
Redux namespace is a map of page path
to page object. The pages reducer takes care of updating this on a CREATE_PAGE
action. It also creates a Foreign Key Reference to the plugin that created the page by adding a pluginCreator___NODE
field.
Update components Redux namespace
The components
Redux namespace is a map of componentPath (file with React component) to the Component object. A Component object is the Page object but with an empty query string (that will be set during Query Extraction).
onCreatePage API
Every time a page is created, plugins have the opportunity to handle its onCreatePage event. This is used for things like creating SitePage
nodes in Internal Data Bridge, and for “path” related plugins such as gatsby-plugin-create-client-paths and gatsby-plugin-remove-trailing-slashes.