Upgrade to alpha-2

This commit is contained in:
Kyle Mathews 2016-09-20 22:23:54 -07:00
parent 94a2ab7ea3
commit 640be90860
12 changed files with 200 additions and 116 deletions

View file

@ -1,74 +0,0 @@
import React from 'react'
import { Link } from 'react-router'
import { Container } from 'react-responsive-grid'
import { prefixLink } from 'gatsby-helpers'
import { rhythm, adjustFontSizeToMSValue } from 'utils/typography'
import { config } from 'config'
class Template extends React.Component {
render () {
const { location, children } = this.props
let header
if (location.pathname === prefixLink('/')) {
header = (
<h1
style={{
...adjustFontSizeToMSValue(1.5),
marginBottom: rhythm(1.5),
marginTop: 0,
}}
>
<Link
style={{
boxShadow: 'none',
textDecoration: 'none',
color: 'inherit',
}}
to={prefixLink('/')}
>
{config.blogTitle}
</Link>
</h1>
)
} else {
header = (
<h3
style={{
fontFamily: 'Montserrat, sans-serif',
marginTop: 0,
}}
>
<Link
style={{
boxShadow: 'none',
textDecoration: 'none',
color: 'inherit',
}}
to={prefixLink('/')}
>
{config.blogTitle}
</Link>
</h3>
)
}
return (
<Container
style={{
maxWidth: rhythm(24),
padding: `${rhythm(1.5)} ${rhythm(3/4)}`,
}}
>
{header}
{children}
</Container>
)
}
}
Template.propTypes = {
children: React.PropTypes.any,
location: React.PropTypes.object,
route: React.PropTypes.object,
}
export default Template

View file

@ -1,38 +1,39 @@
import React from 'react'
import { Link } from 'react-router'
import sortBy from 'lodash/sortBy'
import get from 'lodash/get'
import DocumentTitle from 'react-document-title'
import { prefixLink } from 'gatsby-helpers'
import { rhythm } from 'utils/typography'
import access from 'safe-access'
import { config } from 'config'
import include from 'underscore.string/include'
import Bio from 'components/Bio'
class BlogIndex extends React.Component {
render () {
const pageLinks = []
// Sort pages.
const sortedPages = sortBy(this.props.route.pages, (page) =>
access(page, 'data.date')
).reverse()
sortedPages.forEach((page) => {
if (access(page, 'file.ext') === 'md' && !include(page.path, '/404')) {
const title = access(page, 'data.title') || page.path
const posts = get(this, 'props.data.allMarkdown.edges')
posts.forEach((post) => {
if (post.node.path !== '/404/') {
const title = get(post, 'node.frontmatter.title') || post.node.path
pageLinks.push(
<li
key={page.path}
key={post.node.path}
style={{
marginBottom: rhythm(1/4),
}}
>
<Link style={{boxShadow: 'none'}} to={prefixLink(page.path)}>{title}</Link>
<Link
style={{boxShadow: 'none'}}
to={prefixLink(post.node.path)}
>
{post.node.frontmatter.title}
</Link>
</li>
)
}
})
return (
<DocumentTitle title={config.blogTitle}>
<DocumentTitle title={get(this, 'props.data.site.siteMetadata.title')}>
<div>
<Bio />
<ul>
@ -49,3 +50,24 @@ BlogIndex.propTypes = {
}
export default BlogIndex
export const pageQuery = `
{
site {
buildTime
siteMetadata {
title
}
}
allMarkdown(first: 2000) {
edges {
node {
path
frontmatter {
title
}
}
}
}
}
`