Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
gatsby-plugin-page-creator
Advanced tools
Gatsby plugin that automatically creates pages from React components in specified directories
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.
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`],
},
},
],
};
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 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 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 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
.
You may include another instance of this plugin if you'd like to create additional "pages" directories.
With this plugin, any file that lives in the the specified pages folder (e.g. the default src/pages
) 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
_*
.*
To exclude custom patterns, see Ignoring Specific Files
npm install --save gatsby-plugin-page-creator
// gatsby-config.js
module.exports = {
plugins: [
// You can have multiple instances of this plugin
// to create pages from React components in different directories.
//
// The following sets up the pattern of having multiple
// "pages" directories in your project
{
resolve: `gatsby-plugin-page-creator`,
options: {
path: `${__dirname}/src/account/pages`,
},
},
{
resolve: `gatsby-plugin-page-creator`,
options: {
path: `${__dirname}/src/settings/pages`,
},
},
],
}
// The following example will disable the `/blog` index page
// gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-page-creator`,
options: {
path: `${__dirname}/src/indexes/pages`,
ignore: [`blog.(js|ts)?(x)`],
// See pattern syntax recognized by micromatch
// https://www.npmjs.com/package/micromatch#matching-features
},
},
],
}
NOTE: The above code snippet will only stop the creation of the /blog
page, which is defined as a React component.
This plugin does not affect programmatically generated pages from the createPagesAPI.
// The following example will ignore pages using case-insensitive matching
// gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-page-creator`,
options: {
path: `${__dirname}/src/examples/pages`,
ignore: {
// Example: Ignore `file.example.js`, `dir/s/file.example.tsx`
patterns: [`**/*.example.(js|ts)?(x)`],
// Example: Match both `file.example.js` and `file.EXAMPLE.js`
options: { nocase: true },
// See all available micromatch options
// https://www.npmjs.com/package/micromatch#optionsnocase
},
},
},
],
}
FAQs
Gatsby plugin that automatically creates pages from React components in specified directories
The npm package gatsby-plugin-page-creator receives a total of 226,569 weekly downloads. As such, gatsby-plugin-page-creator popularity was classified as popular.
We found that gatsby-plugin-page-creator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.