1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2025-01-03 18:35:00 +01:00

location.pathname refactor

This commit is contained in:
Matthias Kretschmann 2018-04-11 20:15:35 +02:00
parent 6583adf28c
commit 946c02f8af
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 8 additions and 4 deletions

View File

@ -5,11 +5,11 @@ import Social from './Social'
import { Logo } from '../atoms/Icons' import { Logo } from '../atoms/Icons'
import './Header.scss' import './Header.scss'
const Header = ({ meta }) => { const Header = ({ meta, isHomepage}) => {
const isHomepage = location.pathname === '/'
const classes = isHomepage ? 'header' : 'header header--minimal' const classes = isHomepage ? 'header' : 'header header--minimal'
return <header className={classes}> return (
<header className={classes}>
<Link className="header__name" to={'/'}> <Link className="header__name" to={'/'}>
<Logo className="header__logo" /> <Logo className="header__logo" />
<h1 className="header__title">{meta.title}</h1> <h1 className="header__title">{meta.title}</h1>
@ -18,10 +18,12 @@ const Header = ({ meta }) => {
<Social meta={meta} minimal={!isHomepage} /> <Social meta={meta} minimal={!isHomepage} />
</header> </header>
)
} }
Header.propTypes = { Header.propTypes = {
meta: PropTypes.object, meta: PropTypes.object,
isHomepage: PropTypes.bool,
} }
export default Header export default Header

View File

@ -8,10 +8,11 @@ import './index.scss'
const TemplateWrapper = props => { const TemplateWrapper = props => {
const meta = props.data.allDataJson.edges[0].node const meta = props.data.allDataJson.edges[0].node
const isHomepage = props.location.pathname === '/'
return <div className="app"> return <div className="app">
<Head meta={meta} /> <Head meta={meta} />
<Header meta={meta} /> <Header meta={meta} isHomepage={isHomepage} />
<FadeIn>{props.children()}</FadeIn> <FadeIn>{props.children()}</FadeIn>
<Footer meta={meta} /> <Footer meta={meta} />
</div> </div>
@ -20,6 +21,7 @@ const TemplateWrapper = props => {
TemplateWrapper.propTypes = { TemplateWrapper.propTypes = {
children: PropTypes.func, children: PropTypes.func,
data: PropTypes.object, data: PropTypes.object,
location: PropTypes.object,
} }
export default TemplateWrapper export default TemplateWrapper