Skip to content

Instantly share code, notes, and snippets.

@yomete
Created July 29, 2019 04:27
Show Gist options
  • Save yomete/a2dd1ca059405fbc0b5c90f117142e1c to your computer and use it in GitHub Desktop.
Save yomete/a2dd1ca059405fbc0b5c90f117142e1c to your computer and use it in GitHub Desktop.
import React from "react"
import { Link } from "gatsby"
import { rhythm, scale } from "../utils/typography"
interface Props {
location: Location
title: string
children?: any
}
const Layout = ({ location, title, children }: Props) => {
const rootPath = `${__PATH_PREFIX__}/`
let header
if (location.pathname === rootPath) {
header = (
<h1
style={{
...scale(1.5),
marginBottom: rhythm(1.5),
marginTop: 0,
}}
>
<Link
style={{
boxShadow: `none`,
textDecoration: `none`,
color: `inherit`,
}}
to={`/`}
>
{title}
</Link>
</h1>
)
} else {
header = (
<h3
style={{
fontFamily: `Montserrat, sans-serif`,
marginTop: 0,
}}
>
<Link
style={{
boxShadow: `none`,
textDecoration: `none`,
color: `inherit`,
}}
to={`/`}
>
{title}
</Link>
</h3>
)
}
return (
<div
style={{
marginLeft: `auto`,
marginRight: `auto`,
maxWidth: rhythm(24),
padding: `${rhythm(1.5)} ${rhythm(3 / 4)}`,
}}
>
<header>{header}</header>
<main>{children}</main>
<footer>
© {new Date().getFullYear()}, Built with
{` `}
<a href="https://www.gatsbyjs.org">Gatsby</a>
</footer>
</div>
)
}
export default Layout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment