gatsby-plugin-layout
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -6,2 +6,8 @@ # Change Log | ||
<a name="1.0.6"></a> | ||
## [1.0.6](https://github.com/gatsbyjs/gatsby/compare/gatsby-plugin-layout@1.0.5...gatsby-plugin-layout@1.0.6) (2018-10-30) | ||
**Note:** Version bump only for package gatsby-plugin-layout | ||
<a name="1.0.5"></a> | ||
@@ -8,0 +14,0 @@ |
{ | ||
"name": "gatsby-plugin-layout", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Reimplements the behavior of layout components in gatsby@1, which was removed in version 2.", | ||
@@ -34,3 +34,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "dbd71c33ced0829c5f4bc552127ef80b4a7398a5" | ||
"gitHead": "ce24780bca47ad53f52f8c0eab86e46f8189cf9a" | ||
} |
@@ -182,1 +182,31 @@ # gatsby-plugin-layout | ||
``` | ||
### Handling multiple layouts | ||
If you want to use different layouts for different pages, you can pass this information in the context of the pages you create, and then conditionally render in your layout file. | ||
In `gatsby-node.js`: | ||
```js | ||
exports.onCreatePage = ({ page, actions }) => { | ||
const { createPage } = actions | ||
if(page.path.match(/special-page/) { | ||
page.context.layout = 'special' | ||
createPage(page) | ||
} | ||
} | ||
``` | ||
And then in `src/layouts/index.js`: | ||
```js | ||
export default ({ children, pageContext }) => { | ||
if (pageContext.layout === 'special') { | ||
return <AlternativeLayout>{children}</AlternativeLayout> | ||
} | ||
return ( | ||
<RegularLayout>{children}</RegularLayout> | ||
) | ||
} | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12870
212