What is gatsby-plugin-page-creator?
The gatsby-plugin-page-creator package is a Gatsby plugin that automatically creates pages from React components in specified directories. This helps streamline the process of adding new pages to a Gatsby site by eliminating the need to manually configure each page in the gatsby-node.js file.
What are gatsby-plugin-page-creator's main functionalities?
Automatic Page Creation
Automatically creates pages from React components located in the specified directory (`src/pages` in this example).
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-page-creator`,
options: {
path: `${__dirname}/src/pages`,
},
},
],
};
Custom Path Configuration
Allows you to specify a custom directory (`src/custom-pages` in this example) from which to create pages.
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-page-creator`,
options: {
path: `${__dirname}/src/custom-pages`,
},
},
],
};
File Extension Support
Supports multiple file extensions for page components, such as `.js`, `.jsx`, `.ts`, and `.tsx`.
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-page-creator`,
options: {
path: `${__dirname}/src/pages`,
extensions: [`.js`, `.jsx`, `.ts`, `.tsx`],
},
},
],
};
Other packages similar to gatsby-plugin-page-creator
gatsby-plugin-mdx
gatsby-plugin-mdx is a plugin for using MDX (Markdown with JSX) in Gatsby. It allows you to create pages from MDX files, which can include React components. This plugin is useful if you prefer writing content in Markdown but still want to leverage React components within your pages.
gatsby-source-filesystem
gatsby-source-filesystem is a plugin that allows you to source data into your Gatsby application from the local filesystem. While it doesn't create pages directly, it is often used in conjunction with other plugins like gatsby-transformer-remark or gatsby-plugin-mdx to create pages from Markdown or MDX files.
gatsby-plugin-create-client-paths
gatsby-plugin-create-client-paths is a plugin that allows you to create client-only routes in your Gatsby application. This is useful for creating dynamic routes that are not known at build time, such as user profiles or other personalized content.
gatsby-plugin-page-creator
Gatsby plugin that automatically creates pages from React components in specified directories. Gatsby
includes this plugin automatically in all sites for creating pages from components in src/pages
.
With this plugin, any file that lives in the src/pages
folder (or subfolders) will be expected to export a React Component to generate a Page. The following files are automatically excluded:
template-*
__tests__/*
*.test.jsx?
*.spec.jsx?
*.d.tsx?
*.json
*.yaml
_*
.*
Install
npm install --save gatsby-plugin-page-creator
How to use
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-page-creator`,
options: {
path: `${__dirname}/src/account/pages`,
},
},
{
resolve: `gatsby-plugin-page-creator`,
options: {
path: `${__dirname}/src/settings/pages`,
},
},
],
}