update starter blog for alpha18
This commit is contained in:
parent
4f47229cb6
commit
13430a68d1
1 changed files with 6 additions and 6 deletions
|
|
@ -5,7 +5,7 @@ const select = require(`unist-util-select`)
|
|||
const fs = require(`fs-extra`)
|
||||
|
||||
exports.createPages = ({ graphql, boundActionCreators }) => {
|
||||
const { upsertPage } = boundActionCreators
|
||||
const { createPage } = boundActionCreators
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const pages = []
|
||||
|
|
@ -33,7 +33,7 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
|
|||
|
||||
// Create blog posts pages.
|
||||
_.each(result.data.allMarkdownRemark.edges, edge => {
|
||||
upsertPage({
|
||||
createPage({
|
||||
path: edge.node.fields.slug, // required
|
||||
component: blogPost,
|
||||
context: {
|
||||
|
|
@ -47,15 +47,15 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
|
|||
}
|
||||
|
||||
// Add custom slug for blog posts to both File and MarkdownRemark nodes.
|
||||
exports.onNodeCreate = ({ node, boundActionCreators, getNode }) => {
|
||||
const { addFieldToNode } = boundActionCreators
|
||||
exports.onCreateNode = ({ node, boundActionCreators, getNode }) => {
|
||||
const { createNodeField } = boundActionCreators
|
||||
if (node.internal.type === `File`) {
|
||||
const parsedFilePath = path.parse(node.relativePath)
|
||||
const slug = `/${parsedFilePath.dir}/`
|
||||
addFieldToNode({ node, fieldName: `slug`, fieldValue: slug })
|
||||
createNodeField({ node, fieldName: `slug`, fieldValue: slug })
|
||||
} else if (node.internal.type === `MarkdownRemark`) {
|
||||
const fileNode = getNode(node.parent)
|
||||
addFieldToNode({
|
||||
createNodeField({
|
||||
node,
|
||||
fieldName: `slug`,
|
||||
fieldValue: fileNode.fields.slug,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue