-
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.
create public page renderer and export correct version (dev / prod) d…
…epending on NODE_ENV
- Loading branch information
Showing
4 changed files
with
52 additions
and
18 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
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,23 @@ | ||
import React from "react" | ||
import PropTypes from "prop-types" | ||
|
||
import pages from "./pages.json" | ||
import loader from "./loader" | ||
import JSONStore from "./json-store" | ||
|
||
const DevPageRenderer = ({ location }) => { | ||
const pageResources = loader.getResourcesForPathname(location.pathname) | ||
return React.createElement(JSONStore, { | ||
pages, | ||
location, | ||
pageResources, | ||
}) | ||
} | ||
|
||
DevPageRenderer.propTypes = { | ||
location: PropTypes.shape({ | ||
pathname: PropTypes.string.isRequired, | ||
}).isRequired, | ||
} | ||
|
||
export default DevPageRenderer |
21 changes: 21 additions & 0 deletions
21
packages/gatsby/src/cache-dir/public-page-renderer-prod.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,21 @@ | ||
import React from "react" | ||
import PropTypes from "prop-types" | ||
|
||
import InternalPageRenderer from "./page-renderer" | ||
import loader from "./loader" | ||
|
||
const ProdPageRenderer = ({ location }) => { | ||
const pageResources = loader.getResourcesForPathname(location.pathname) | ||
return React.createElement(InternalPageRenderer, { | ||
location, | ||
pageResources, | ||
}) | ||
} | ||
|
||
ProdPageRenderer.propTypes = { | ||
location: PropTypes.shape({ | ||
pathname: PropTypes.string.isRequired, | ||
}).isRequired, | ||
} | ||
|
||
export default ProdPageRenderer |
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,7 @@ | ||
const preferDefault = m => (m && m.default) || m | ||
|
||
if (process.env.NODE_ENV === `production`) { | ||
module.exports = preferDefault(require(`./public-page-renderer-prod`)) | ||
} else { | ||
module.exports = preferDefault(require(`./public-page-renderer-dev`)) | ||
} |