Merge pull request #126 from bradwoods/layout-name-convention-fix

Update layout to match convention
This commit is contained in:
Joaquin Bravo 2018-11-04 11:10:31 -06:00 committed by GitHub
commit b6632e0e10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 75 additions and 4 deletions

71
src/components/Layout.js Normal file
View file

@ -0,0 +1,71 @@
import React from 'react'
import { Link } from 'gatsby'
import { rhythm, scale } from '../utils/typography'
class Layout extends React.Component {
render() {
const { location, children } = this.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={'/'}
>
Gatsby Starter Blog
</Link>
</h1>
)
} else {
header = (
<h3
style={{
fontFamily: 'Montserrat, sans-serif',
marginTop: 0,
marginBottom: rhythm(-1),
}}
>
<Link
style={{
boxShadow: 'none',
textDecoration: 'none',
color: 'inherit',
}}
to={'/'}
>
Gatsby Starter Blog
</Link>
</h3>
)
}
return (
<div
style={{
marginLeft: 'auto',
marginRight: 'auto',
maxWidth: rhythm(24),
padding: `${rhythm(1.5)} ${rhythm(3 / 4)}`,
}}
>
{header}
{children}
</div>
)
}
}
export default Layout

View file

@ -3,7 +3,7 @@ import { Link } from 'gatsby'
import { rhythm, scale } from '../utils/typography'
class Template extends React.Component {
class Layout extends React.Component {
render() {
const { location, children } = this.props
const rootPath = `${__PATH_PREFIX__}/`
@ -68,4 +68,4 @@ class Template extends React.Component {
}
}
export default Template
export default Layout

View file

@ -4,7 +4,7 @@ import get from 'lodash/get'
import Helmet from 'react-helmet'
import Bio from '../components/Bio'
import Layout from '../components/layout'
import Layout from '../components/Layout'
import { rhythm } from '../utils/typography'
class BlogIndex extends React.Component {

View file

@ -4,7 +4,7 @@ import { Link,graphql } from 'gatsby'
import get from 'lodash/get'
import Bio from '../components/Bio'
import Layout from '../components/layout'
import Layout from '../components/Layout'
import { rhythm, scale } from '../utils/typography'
class BlogPostTemplate extends React.Component {