Upgrade to latest canary

This commit is contained in:
Kyle Mathews 2017-04-11 18:00:00 -07:00
parent 1eb4820ba3
commit b7d1dbf4e1
3 changed files with 867 additions and 143 deletions

View file

@ -1,15 +1,15 @@
const _ = require("lodash")
const Promise = require("bluebird")
const path = require("path")
const select = require(`unist-util-select`)
const fs = require(`fs-extra`)
const _ = require("lodash");
const Promise = require("bluebird");
const path = require("path");
const select = require(`unist-util-select`);
const fs = require(`fs-extra`);
exports.createPages = ({ args }) => {
const { graphql } = args
exports.createPages = ({ graphql, actionCreators }) => {
const { upsertPage } = actionCreators;
return new Promise((resolve, reject) => {
const pages = []
const blogPost = path.resolve("templates/template-blog-post.js")
const pages = [];
const blogPost = path.resolve("templates/template-blog-post.js");
graphql(
`
{
@ -24,43 +24,39 @@ exports.createPages = ({ args }) => {
`
).then(result => {
if (result.errors) {
console.log(result.errors)
reject(result.errors)
console.log(result.errors);
reject(result.errors);
}
// Create blog posts pages.
_.each(result.data.allMarkdownRemark.edges, edge => {
pages.push({
upsertPage({
path: edge.node.slug, // required
component: blogPost,
context: {
slug: edge.node.slug,
},
})
})
});
});
resolve(pages)
})
})
}
resolve();
});
});
};
// Add custom url pathname for blog posts.
exports.modifyAST = ({ args }) => {
const { ast } = args
const files = select(ast, "File")
files.forEach(file => {
if (file.extension !== `md`) {
return
}
const parsedFilePath = path.parse(file.relativePath)
console.log(parsedFilePath)
const slug = `/${parsedFilePath.dir}/`
console.log(slug)
file.slug = slug
const markdownNode = select(file, `MarkdownRemark`)[0]
if (markdownNode) {
markdownNode.slug = slug
}
})
return files
exports.onNodeCreate = ({ node, actionCreators, getNode }) => {
const { updateNode } = actionCreators;
if (node.type === `File` && typeof node.slug === "undefined") {
const parsedFilePath = path.parse(node.relativePath);
const slug = `/${parsedFilePath.dir}/`;
node.slug = slug;
updateNode(node);
} else if (
node.type === `MarkdownRemark` && typeof node.slug === "undefined"
) {
const fileNode = getNode(node.parent);
node.slug = fileNode.slug;
updateNode(node);
}
};

View file

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

904
yarn.lock

File diff suppressed because it is too large Load diff