Update starter to latest canary

This commit is contained in:
Kyle Mathews 2017-05-19 11:57:38 +02:00
parent 1d2329c1c9
commit 6a806c21cd
8 changed files with 1295 additions and 1624 deletions

View file

@ -11,32 +11,29 @@ module.exports = {
name: "pages", name: "pages",
}, },
}, },
`gatsby-transformer-remark`,
`gatsby-transformer-sharp`,
{ {
resolve: `gatsby-typegen-remark`, resolve: `gatsby-transformer-remark`,
options: { options: {
plugins: [ plugins: [
{ {
resolve: `gatsby-typegen-remark-responsive-image`, resolve: `gatsby-remark-responsive-image`,
options: { options: {
maxWidth: 590, maxWidth: 590,
}, },
}, },
{ {
resolve: `gatsby-typegen-remark-responsive-iframe`, resolve: `gatsby-remark-responsive-iframe`,
options: { options: {
wrapperStyle: `margin-bottom: 1.0725rem`, wrapperStyle: `margin-bottom: 1.0725rem`,
}, },
}, },
"gatsby-typegen-remark-prismjs", "gatsby-remark-prismjs",
"gatsby-typegen-remark-copy-linked-files", "gatsby-remark-copy-linked-files",
"gatsby-typegen-remark-smartypants", "gatsby-remark-smartypants",
], ],
}, },
}, },
`gatsby-typegen-filesystem`, `gatsby-transformer-sharp`,
`gatsby-typegen-sharp`,
`gatsby-plugin-sharp`, `gatsby-plugin-sharp`,
{ {
resolve: `gatsby-plugin-google-analytics`, resolve: `gatsby-plugin-google-analytics`,

View file

@ -10,8 +10,9 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const pages = [] const pages = []
const blogPost = path.resolve("./src/templates/template-blog-post.js") const blogPost = path.resolve("./src/templates/template-blog-post.js")
graphql( resolve(
` graphql(
`
{ {
allMarkdownRemark(limit: 1000) { allMarkdownRemark(limit: 1000) {
edges { edges {
@ -22,38 +23,37 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
} }
} }
` `
).then(result => { ).then(result => {
if (result.errors) { if (result.errors) {
console.log(result.errors) console.log(result.errors)
reject(result.errors) reject(result.errors)
} }
// Create blog posts pages. // Create blog posts pages.
_.each(result.data.allMarkdownRemark.edges, edge => { _.each(result.data.allMarkdownRemark.edges, edge => {
upsertPage({ upsertPage({
path: edge.node.slug, // required path: edge.node.slug, // required
component: blogPost, component: blogPost,
context: { context: {
slug: edge.node.slug, slug: edge.node.slug,
}, },
})
}) })
}) })
)
resolve()
})
}) })
} }
// Add custom url pathname for blog posts. // Add custom url pathname for blog posts.
exports.onNodeCreate = ({ node, boundActionCreators, getNode }) => { exports.onNodeCreate = ({ node, boundActionCreators, getNode }) => {
const { updateNode } = boundActionCreators const { updateNode } = boundActionCreators
if (node.type === `File` && typeof node.slug === "undefined") { if (node.internal.type === `File` && typeof node.slug === "undefined") {
const parsedFilePath = path.parse(node.relativePath) const parsedFilePath = path.parse(node.relativePath)
const slug = `/${parsedFilePath.dir}/` const slug = `/${parsedFilePath.dir}/`
node.slug = slug node.slug = slug
updateNode(node) updateNode(node)
} else if ( } else if (
node.type === `MarkdownRemark` && node.internal.type === `MarkdownRemark` &&
typeof node.slug === "undefined" typeof node.slug === "undefined"
) { ) {
const fileNode = getNode(node.parent) const fileNode = getNode(node.parent)

View file

@ -7,24 +7,21 @@
"url": "https://github.com/gatsbyjs/gatsby-starter-blog/issues" "url": "https://github.com/gatsbyjs/gatsby-starter-blog/issues"
}, },
"dependencies": { "dependencies": {
"gatsby": "1.0.0-alpha13", "gatsby": "canary",
"gatsby-link": "1.0.0-alpha13", "gatsby-link": "canary",
"gatsby-transformer-remark": "1.0.0-alpha13", "gatsby-transformer-remark": "canary",
"gatsby-transformer-sharp": "1.0.0-alpha13", "gatsby-transformer-sharp": "canary",
"gatsby-plugin-google-analytics": "1.0.0-alpha13", "gatsby-plugin-google-analytics": "canary",
"gatsby-plugin-manifest": "1.0.0-alpha13", "gatsby-plugin-manifest": "canary",
"gatsby-plugin-offline": "1.0.0-alpha13", "gatsby-plugin-offline": "canary",
"gatsby-plugin-preact": "1.0.0-alpha13", "gatsby-plugin-preact": "canary",
"gatsby-plugin-sharp": "1.0.0-alpha13", "gatsby-plugin-sharp": "canary",
"gatsby-source-filesystem": "1.0.0-alpha13", "gatsby-source-filesystem": "canary",
"gatsby-typegen-filesystem": "1.0.0-alpha13", "gatsby-remark-copy-linked-files": "canary",
"gatsby-typegen-remark": "1.0.0-alpha13", "gatsby-remark-prismjs": "canary",
"gatsby-typegen-remark-copy-linked-files": "1.0.0-alpha13", "gatsby-remark-responsive-iframe": "canary",
"gatsby-typegen-remark-prismjs": "1.0.0-alpha13", "gatsby-remark-responsive-image": "canary",
"gatsby-typegen-remark-responsive-iframe": "1.0.0-alpha13", "gatsby-remark-smartypants": "canary",
"gatsby-typegen-remark-responsive-image": "1.0.0-alpha13",
"gatsby-typegen-remark-smartypants": "1.0.0-alpha13",
"gatsby-typegen-sharp": "1.0.0-alpha13",
"lodash": "^4.15.0", "lodash": "^4.15.0",
"moment": "^2.14.1", "moment": "^2.14.1",
"react-helmet": "^4.0.0", "react-helmet": "^4.0.0",

View file

@ -44,7 +44,7 @@ module.exports = React.createClass({
</head> </head>
<body> <body>
<div <div
id="react-mount" id="___gatsby"
dangerouslySetInnerHTML={{ __html: this.props.body }} dangerouslySetInnerHTML={{ __html: this.props.body }}
/> />
{this.props.postBodyComponents} {this.props.postBodyComponents}

View file

@ -59,14 +59,14 @@ class Template extends React.Component {
}} }}
> >
{header} {header}
{children} {children()}
</Container> </Container>
) )
} }
} }
Template.propTypes = { Template.propTypes = {
children: React.PropTypes.any, children: React.PropTypes.function,
location: React.PropTypes.object, location: React.PropTypes.object,
route: React.PropTypes.object, route: React.PropTypes.object,
} }

View file

@ -9,7 +9,7 @@ import { rhythm } from "../utils/typography"
class BlogIndex extends React.Component { class BlogIndex extends React.Component {
render() { render() {
console.log(this.props) // console.log("props", this.props)
const pageLinks = [] const pageLinks = []
const siteTitle = get(this, "props.data.site.siteMetadata.title") const siteTitle = get(this, "props.data.site.siteMetadata.title")
const posts = get(this, "props.data.allMarkdownRemark.edges") const posts = get(this, "props.data.allMarkdownRemark.edges")
@ -49,8 +49,8 @@ BlogIndex.propTypes = {
export default BlogIndex export default BlogIndex
export const pageQuery = ` export const pageQuery = graphql`
{ query IndexQuery {
site { site {
siteMetadata { siteMetadata {
title title

View file

@ -10,7 +10,7 @@ class BlogPostRoute extends React.Component {
render() { render() {
const post = this.props.data.markdownRemark const post = this.props.data.markdownRemark
const siteTitle = get(this.props, "data.site.siteMetadata.title") const siteTitle = get(this.props, "data.site.siteMetadata.title")
console.log(this.props) // console.log(this.props)
return ( return (
<div> <div>
@ -40,7 +40,7 @@ class BlogPostRoute extends React.Component {
export default BlogPostRoute export default BlogPostRoute
export const pageQuery = ` export const pageQuery = graphql`
query BlogPostByPath($slug: String!) { query BlogPostByPath($slug: String!) {
site { site {
siteMetadata { siteMetadata {

2813
yarn.lock

File diff suppressed because it is too large Load diff