Upgrades for Gatsby 0.8
This commit is contained in:
parent
066c8013c4
commit
4d3c5ca244
6 changed files with 59 additions and 48 deletions
3
.babelrc
3
.babelrc
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"stage": 2,
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +1,16 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Link } from 'react-router'
|
import { Link } from 'react-router'
|
||||||
import { prune, include as includes } from 'underscore.string'
|
import { prune, include as includes } from 'underscore.string'
|
||||||
import find from 'lodash/collection/find'
|
import find from 'lodash/find'
|
||||||
import { rhythm, fontSizeToMS } from 'utils/typography'
|
import { rhythm, fontSizeToMS } from 'utils/typography'
|
||||||
|
|
||||||
export default class ReadNext extends React.Component {
|
class ReadNext extends React.Component {
|
||||||
propTypes () {
|
|
||||||
return {
|
|
||||||
post: React.PropTypes.object,
|
|
||||||
pages: React.PropTypes.object,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
render () {
|
render () {
|
||||||
const readNext = this.props.post.readNext
|
const readNext = this.props.post.readNext
|
||||||
let nextPost
|
let nextPost
|
||||||
if (readNext !== null) {
|
if (readNext) {
|
||||||
nextPost = find(this.props.pages, (page) =>
|
nextPost = find(this.props.pages, (page) =>
|
||||||
includes(page.path, readNext.slice(1, -1))
|
includes(page.path, readNext)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (!nextPost) {
|
if (!nextPost) {
|
||||||
|
|
@ -47,8 +41,12 @@ export default class ReadNext extends React.Component {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Link
|
<Link
|
||||||
to={nextPost.path}
|
to={{
|
||||||
query={{ readNext: true }}
|
pathname: nextPost.path,
|
||||||
|
query: {
|
||||||
|
readNext: true,
|
||||||
|
},
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{nextPost.data.title}
|
{nextPost.data.title}
|
||||||
</Link>
|
</Link>
|
||||||
|
|
@ -60,3 +58,10 @@ export default class ReadNext extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReadNext.propTypes = {
|
||||||
|
post: React.PropTypes.object.isRequired,
|
||||||
|
pages: React.PropTypes.array,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ReadNext
|
||||||
|
|
|
||||||
16
package.json
16
package.json
|
|
@ -21,20 +21,24 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/gatsbyjs/gatsby-starter-blog#readme",
|
"homepage": "https://github.com/gatsbyjs/gatsby-starter-blog#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lodash": "^3.10.1",
|
"lodash": "^4.5.0",
|
||||||
"moment": "^2.10.3",
|
"moment": "^2.10.3",
|
||||||
"react": "^0.14.3",
|
"react": "^0.14.7",
|
||||||
"react-document-title": "^2.0.1",
|
"react-document-title": "^2.0.1",
|
||||||
"react-dom": "^0.14.3",
|
"react-dom": "^0.14.7",
|
||||||
"react-responsive-grid": "^0.3.0",
|
"react-responsive-grid": "^0.3.0",
|
||||||
"react-router": "^0.13.5",
|
"react-router": "^2.0.0",
|
||||||
"safe-access": "^0.1.0",
|
"safe-access": "^0.1.0",
|
||||||
"typography": "^0.6.2",
|
"typography": "^0.7.0",
|
||||||
"underscore.string": "^3.2.2"
|
"underscore.string": "^3.2.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"babel-plugin-react-transform": "^1.1.1",
|
||||||
"eslint": "^1.10.3",
|
"eslint": "^1.10.3",
|
||||||
"eslint-config-airbnb": "^5.0.1",
|
"eslint-config-airbnb": "^5.0.1",
|
||||||
"eslint-plugin-react": "^4.0.0"
|
"eslint-plugin-react": "^4.0.0",
|
||||||
|
"react-transform-catch-errors": "^1.0.0",
|
||||||
|
"react-transform-hmr": "^1.0.0",
|
||||||
|
"redbox-react": "^1.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { RouteHandler, Link } from 'react-router'
|
import { Link } from 'react-router'
|
||||||
import { Container } from 'react-responsive-grid'
|
import { Container } from 'react-responsive-grid'
|
||||||
import { link } from 'gatsby-helpers'
|
import { link } from 'gatsby-helpers'
|
||||||
import { rhythm, fontSizeToMS } from 'utils/typography'
|
import { rhythm, fontSizeToMS } from 'utils/typography'
|
||||||
|
|
@ -7,15 +7,10 @@ import { config } from 'config'
|
||||||
|
|
||||||
import '../css/styles.css'
|
import '../css/styles.css'
|
||||||
|
|
||||||
export default class extends React.Component {
|
class Template extends React.Component {
|
||||||
propTypes () {
|
|
||||||
return {
|
|
||||||
route: React.PropTypes.object,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
render () {
|
render () {
|
||||||
let header
|
let header
|
||||||
if (this.props.route.path === link('/')) {
|
if (this.props.location.pathname === link('/')) {
|
||||||
header = (
|
header = (
|
||||||
<h1
|
<h1
|
||||||
style={{
|
style={{
|
||||||
|
|
@ -58,8 +53,16 @@ export default class extends React.Component {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{header}
|
{header}
|
||||||
<RouteHandler {...this.props}/>
|
{this.props.children}
|
||||||
</Container>
|
</Container>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Template.propTypes = {
|
||||||
|
children: React.PropTypes.any,
|
||||||
|
location: React.PropTypes.object,
|
||||||
|
route: React.PropTypes.object,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Template
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,7 @@ import { rhythm } from 'utils/typography'
|
||||||
import access from 'safe-access'
|
import access from 'safe-access'
|
||||||
import { config } from 'config'
|
import { config } from 'config'
|
||||||
|
|
||||||
export default class extends React.Component {
|
class BlogIndex extends React.Component {
|
||||||
propTypes () {
|
|
||||||
return {
|
|
||||||
route: React.PropTypes.object,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
render () {
|
render () {
|
||||||
const pageLinks = []
|
const pageLinks = []
|
||||||
// Sort pages.
|
// Sort pages.
|
||||||
|
|
@ -20,8 +15,8 @@ export default class extends React.Component {
|
||||||
access(page, 'data.date')
|
access(page, 'data.date')
|
||||||
).reverse()
|
).reverse()
|
||||||
sortedPages.forEach((page) => {
|
sortedPages.forEach((page) => {
|
||||||
|
if (access(page, 'file.ext') === 'md') {
|
||||||
const title = access(page, 'data.title') || page.path
|
const title = access(page, 'data.title') || page.path
|
||||||
if (page.path && page.path !== '/' && access(page, 'file.extension') === '.md') {
|
|
||||||
pageLinks.push(
|
pageLinks.push(
|
||||||
<li
|
<li
|
||||||
key={page.path}
|
key={page.path}
|
||||||
|
|
@ -62,3 +57,9 @@ export default class extends React.Component {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BlogIndex.propTypes = {
|
||||||
|
route: React.PropTypes.object,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BlogIndex
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,7 @@ import { config } from 'config'
|
||||||
|
|
||||||
import '../css/zenburn.css'
|
import '../css/zenburn.css'
|
||||||
|
|
||||||
module.exports = React.createClass({
|
class MarkdownWrapper extends React.Component {
|
||||||
propTypes () {
|
|
||||||
return {
|
|
||||||
route: React.PropTypes.object,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
render () {
|
render () {
|
||||||
const post = this.props.route.page.data
|
const post = this.props.route.page.data
|
||||||
|
|
||||||
|
|
@ -35,7 +30,7 @@ module.exports = React.createClass({
|
||||||
marginBottom: rhythm(2),
|
marginBottom: rhythm(2),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ReadNext post={post} {...this.props}/>
|
<ReadNext post={post} pages={this.props.route.pages} />
|
||||||
<p>
|
<p>
|
||||||
<img
|
<img
|
||||||
src={link('/kyle-round-small-pantheon.jpg')}
|
src={link('/kyle-round-small-pantheon.jpg')}
|
||||||
|
|
@ -47,10 +42,16 @@ module.exports = React.createClass({
|
||||||
height: rhythm(2),
|
height: rhythm(2),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<strong>{this.props.config.authorName}</strong> lives and works in San Francisco building useful things. <a href="https://twitter.com/kylemathews">You should follow him on Twitter</a>
|
<strong>{config.authorName}</strong> lives and works in San Francisco building useful things. <a href="https://twitter.com/kylemathews">You should follow him on Twitter</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</DocumentTitle>
|
</DocumentTitle>
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
|
MarkdownWrapper.propTypes = {
|
||||||
|
route: React.PropTypes.object,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MarkdownWrapper
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue