Research
Security News
Malicious npm Package Typosquats react-login-page to Deploy Keylogger
Socket researchers unpack a typosquatting package with malicious code that logs keystrokes and exfiltrates sensitive data to a remote server.
gatsby-plugin-page-creator
Advanced tools
Readme
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 can also leverage the File System Route API to programmatically create pages from your data.
You may include another instance of this plugin if you'd like to create additional "pages" directories or want to override the default usage.
With this plugin, any file that lives in 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 gatsby-plugin-page-creator
Add the plugin to your gatsby-config.js
:
// 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`,
},
},
// You can also overwrite the default behavior for src/pages
// This changes the page-creator instance used by Gatsby
{
resolve: `gatsby-plugin-page-creator`,
options: {
path: `${__dirname}/src/pages`,
ignore: [`foo-bar.js`],
},
},
],
}
The plugin supports options to ignore files and to pass options to the slugify
instance that is used in the File System Route API to create slugs.
Option | Type | Description | Required |
---|---|---|---|
path | string | Any file that lives inside this directory will be expected to export a React component to generate a page | true |
ignore | IPathIgnoreOptions ∣ string ∣ Array<string> ∣ null | Ignore certain files inside the directory specified with path | false |
slugify | ISlugifyOptions | Pass options to the slugify instance that is used inside the File System Route API to generate the slug | false |
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 createPages API.
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
Unknown package
The npm package gatsby-plugin-page-creator receives a total of 177,396 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.
Research
Security News
Socket researchers unpack a typosquatting package with malicious code that logs keystrokes and exfiltrates sensitive data to a remote server.
Security News
The JavaScript community has launched the e18e initiative to improve ecosystem performance by cleaning up dependency trees, speeding up critical parts of the ecosystem, and documenting lighter alternatives to established tools.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.