-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] Extract internal plugin for automatically creating pages so we…
… can reuse for other directories (#4490) * [feat] create page creator plugin A plugin to automatically create pages from a given path. The current method only works when page components are present in src/pages. Now a user can define custom paths to their page components and are not limited to src/pages. * Not sure what I am doing. * remove internal auto page creator Working version using the page creator plugin. Need a better way to resolve. Need a better way to get the version number which is hardcoded right now. * update readme * resolve plugin attributes * [feat] create page creator plugin A plugin to automatically create pages from a given path using react components. The current method only works when page components are present in src/pages. Now a user can define custom paths to their page components and are not limited to src/pages. Signed-off-by: nodox <snatera09@gmail.com> * Update README.md * Update package.json * cleanup the old component-page-creator * simplify loading default `gatsby-plugin-page-creator` plugin using existing functions * add option to skip strict path existence check and use it in default gatsby config * slash default path, update snapshot * move tests to src * update package description * add used packages to dependencies * Update URL * Mention React
- Loading branch information
1 parent
cd9ae49
commit d43ae23
Showing
16 changed files
with
204 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
|
||
decls | ||
dist | ||
|
||
/*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
*.un~ | ||
yarn.lock | ||
src | ||
flow-typed | ||
coverage | ||
decls | ||
examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 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`. | ||
|
||
## Install | ||
|
||
`npm install --save gatsby-plugin-page-creator` | ||
|
||
## How to use | ||
|
||
```javascript | ||
// 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`, | ||
}, | ||
}, | ||
], | ||
}; | ||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "gatsby-plugin-page-creator", | ||
"version": "1.0.0", | ||
"description": "Gatsby plugin that automatically creates pages from React components in specified directories", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "babel src --out-dir . --ignore __tests__", | ||
"watch": "babel -w src --out-dir . --ignore __tests__", | ||
"prepublish": "cross-env NODE_ENV=production npm run build" | ||
}, | ||
"keywords": [ | ||
"gatsby", | ||
"gatsby-plugin" | ||
], | ||
"author": "Kyle Mathews <mathews.kyle@gmail.com>", | ||
"contributors": [ | ||
"Steven Natera <tektekpush@gmail.com> (https://twitter.com/stevennatera)" | ||
], | ||
"license": "MIT", | ||
"dependencies": { | ||
"babel-runtime": "^6.26.0", | ||
"bluebird": "^3.5.0", | ||
"chokidar": "^1.7.0", | ||
"glob": "^7.1.1", | ||
"lodash": "^4.17.4", | ||
"parse-filepath": "^1.0.1", | ||
"slash": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"cross-env": "^5.0.5" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
packages/gatsby/src/internal-plugins/component-page-creator/package.json
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters