🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

gatsby-plugin-layout

Package Overview
Dependencies
Maintainers
2
Versions
262
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-plugin-layout - npm Package Compare versions

Comparing version

to
1.0.6

6

CHANGELOG.md

@@ -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 @@

4

package.json
{
"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>
)
}
```