update starter blog for alpha18

This commit is contained in:
Kyle Mathews 2017-06-02 13:37:24 -07:00
parent 4f47229cb6
commit 13430a68d1

View file

@ -5,7 +5,7 @@ const select = require(`unist-util-select`)
const fs = require(`fs-extra`) const fs = require(`fs-extra`)
exports.createPages = ({ graphql, boundActionCreators }) => { exports.createPages = ({ graphql, boundActionCreators }) => {
const { upsertPage } = boundActionCreators const { createPage } = boundActionCreators
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const pages = [] const pages = []
@ -33,7 +33,7 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
// Create blog posts pages. // Create blog posts pages.
_.each(result.data.allMarkdownRemark.edges, edge => { _.each(result.data.allMarkdownRemark.edges, edge => {
upsertPage({ createPage({
path: edge.node.fields.slug, // required path: edge.node.fields.slug, // required
component: blogPost, component: blogPost,
context: { context: {
@ -47,15 +47,15 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
} }
// Add custom slug for blog posts to both File and MarkdownRemark nodes. // Add custom slug for blog posts to both File and MarkdownRemark nodes.
exports.onNodeCreate = ({ node, boundActionCreators, getNode }) => { exports.onCreateNode = ({ node, boundActionCreators, getNode }) => {
const { addFieldToNode } = boundActionCreators const { createNodeField } = boundActionCreators
if (node.internal.type === `File`) { if (node.internal.type === `File`) {
const parsedFilePath = path.parse(node.relativePath) const parsedFilePath = path.parse(node.relativePath)
const slug = `/${parsedFilePath.dir}/` const slug = `/${parsedFilePath.dir}/`
addFieldToNode({ node, fieldName: `slug`, fieldValue: slug }) createNodeField({ node, fieldName: `slug`, fieldValue: slug })
} else if (node.internal.type === `MarkdownRemark`) { } else if (node.internal.type === `MarkdownRemark`) {
const fileNode = getNode(node.parent) const fileNode = getNode(node.parent)
addFieldToNode({ createNodeField({
node, node,
fieldName: `slug`, fieldName: `slug`,
fieldValue: fileNode.fields.slug, fieldValue: fileNode.fields.slug,