-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: giving different context to same layout don't work
This is a ugly fix for this ref: gatsbyjs/gatsby#3025 fixes #22
- Loading branch information
Showing
2 changed files
with
55 additions
and
2 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,51 @@ | ||
// @flow | ||
import * as React from 'react' | ||
import 'antd/dist/antd.css' | ||
import 'tachyons' // eslint-disable-line | ||
import LanguagesNav from '../components/LanguagesNav' | ||
import './styles.css' | ||
|
||
type Props = { | ||
children: Function, | ||
location: { | ||
// eslint-disable-line | ||
pathname: string, | ||
}, | ||
data: { | ||
contentfulWebsite: { | ||
languageChoiceLabel: string, | ||
}, | ||
}, | ||
layoutContext: { | ||
languages: Array<Object>, | ||
locale: string, | ||
}, | ||
location: { | ||
pathname: string, | ||
}, | ||
} | ||
const MainLayout = ({children, data, layoutContext, location}: Props) => { | ||
const {languageChoiceLabel} = data.contentfulWebsite | ||
const {languages} = layoutContext | ||
const {pathname} = location | ||
return ( | ||
<div> | ||
<LanguagesNav | ||
languageChoiceLabel={languageChoiceLabel} | ||
languages={languages} | ||
pathname={pathname} | ||
/> | ||
{children()} | ||
</div> | ||
) | ||
} | ||
|
||
export default MainLayout | ||
|
||
export const pageQuery = graphql` | ||
query mainLayoutQuery2($locale: String!) { | ||
contentfulWebsite(node_locale: {eq: $locale}) { | ||
languageChoiceLabel | ||
} | ||
} | ||
` |