-
Couldn't load subscription status.
- Fork 10.3k
Description
Description
my goal is to set up relationships between details in frontmatter of several different groups of markdown files. i was able to get this working for gatsby develop with the approach to mapping that i found here. however, when i run gatsby build, it fails with a WebpackError due to failing to read a property of null, which is one of the mapped relationships that worked under gatsby develop. i was able to continue setting up more mappings that worked with gatsby develop but failed the same way with gatsby build.
Steps to reproduce
- clone https://github.com/dsmjs/site
- checkout the
data-structurebranch nvm installnpm installnpm start(runsgatsby develop). load the (early WIP, so no judging :) ) site in the browser and note that things are rendering w/o issuenpm run build(runsgatsby build). note the webpack error
Expected result
gatsby build should complete successfully, resulting in a site that works the same as the one available from gatsby develop
Actual result
8 | return (
9 | <Meeting
> 10 | sponsor={frontmatter.sponsor.frontmatter}
| ^
11 | meeting={frontmatter}
12 | host={frontmatter.host.frontmatter}
13 | talk={frontmatter.talk.frontmatter}
WebpackError: Cannot read property 'frontmatter' of null
Environment
System:
OS: macOS High Sierra 10.13.5
CPU: x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Shell: 4.4.12 - /usr/local/bin/bash
Binaries:
Node: 9.4.0 - ~/development/travi/dotfiles/nvm/.nvm/versions/node/v9.4.0/bin/node
npm: 5.6.0 - ~/development/travi/dotfiles/nvm/.nvm/versions/node/v9.4.0/bin/npm
Browsers:
Chrome: 67.0.3396.87
Firefox: 50.0.1
Safari: 11.1.1
npmPackages:
gatsby: 1.9.272 => 1.9.272
gatsby-link: 1.6.44 => 1.6.44
gatsby-plugin-glamor: 1.6.13 => 1.6.13
gatsby-plugin-google-fonts: 0.0.4 => 0.0.4
gatsby-plugin-react-helmet: 2.0.11 => 2.0.11
gatsby-remark-autolink-headers: 1.4.19 => 1.4.19
gatsby-remark-prismjs: 2.0.4 => 2.0.4
gatsby-source-filesystem: 1.5.39 => 1.5.39
gatsby-transformer-remark: 1.7.43 => 1.7.43
File contents (if changed)
gatsby-config.js:
module.exports = {
siteMetadata: {
title: 'dsmJS - Des Moines JavaScript User Group'
},
mapping: {
'MarkdownRemark.frontmatter.talk': 'MarkdownRemark.frontmatter.title',
'MarkdownRemark.frontmatter.speaker': 'MarkdownRemark.frontmatter.name',
'MarkdownRemark.frontmatter.sponsor': 'MarkdownRemark.frontmatter.name',
'MarkdownRemark.frontmatter.host': 'MarkdownRemark.frontmatter.location'
},
plugins: [
{
resolve: 'gatsby-transformer-remark',
options: {
plugins: [
'gatsby-remark-prismjs',
'gatsby-remark-autolink-headers'
]
}
},
'gatsby-plugin-react-helmet',
'gatsby-plugin-glamor',
{
resolve: 'gatsby-plugin-google-fonts',
options: {
fonts: [
'quicksand:400,500,700'
]
}
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'meetings',
path: `${__dirname}/src/meetings`
}
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'talks',
path: `${__dirname}/src/talks`
}
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'speakers',
path: `${__dirname}/src/speakers`
}
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'sponsors',
path: `${__dirname}/src/sponsors`
}
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'hosts',
path: `${__dirname}/src/hosts`
}
}
]
};package.json:
{
"name": "site",
"description": "Primary website for the dsmJS user-group",
"license": "MIT",
"author": "dsmJS",
"maintainers": [
"Matt Travi <[email protected]> (https://matt.travi.org/)"
],
"private": true,
"repository": "dsmjs/site",
"bugs": "https://github.com/dsmjs/site/issues",
"homepage": "https://github.com/dsmjs/site#readme",
"scripts": {
"lint:md": "globstar --node -- markdownlint **/*.md",
"lint:js": "eslint . --cache",
"test": "run-s lint:* build",
"build": "gatsby build",
"develop": "gatsby develop",
"start": "run-s develop",
"commitmsg": "commitlint -e",
"precommit": "npm test",
"deploy": "gh-pages -r \"https://[email protected]/dsmjs/site.git\" -d public/",
"greenkeeper:update-lockfile": "greenkeeper-lockfile-update",
"greenkeeper:upload-lockfile": "greenkeeper-lockfile-upload"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"devDependencies": {
"@travi/eslint-config-travi": "1.6.14",
"commitlint-config-dsmjs": "1.0.2",
"cz-conventional-changelog": "2.1.0",
"gh-pages": "1.2.0",
"globstar": "1.0.0",
"greenkeeper-lockfile": "1.15.1",
"husky": "1.0.0-rc.9",
"markdownlint-cli": "0.10.0",
"npm-run-all": "4.1.3"
},
"dependencies": {
"@dsmjs/components": "2.0.0-beta",
"gatsby": "1.9.272",
"gatsby-link": "1.6.44",
"gatsby-plugin-glamor": "1.6.13",
"gatsby-plugin-google-fonts": "0.0.4",
"gatsby-plugin-react-helmet": "2.0.11",
"gatsby-remark-autolink-headers": "1.4.19",
"gatsby-remark-prismjs": "2.0.4",
"gatsby-source-filesystem": "1.5.39",
"gatsby-transformer-remark": "1.7.43",
"prismjs": "1.15.0",
"prop-types": "15.6.1",
"react": "16.4.1",
"react-dom": "16.4.1",
"react-helmet": "5.2.0"
}
}gatsby-node.js:
const path = require('path');
const {createFilePath} = require('gatsby-source-filesystem');
exports.onCreateNode = ({node, getNode, boundActionCreators}) => {
const {createNodeField} = boundActionCreators;
if ('MarkdownRemark' === node.internal.type) {
const slug = createFilePath({node, getNode, basePath: 'meetings'});
createNodeField({
node,
name: 'slug',
value: slug
});
}
};
exports.createPages = ({graphql, boundActionCreators}) => {
const {createPage} = boundActionCreators;
return graphql(`
{
allMarkdownRemark {
edges {
node {
fields {
slug
}
}
}
}
}
`).then(result => {
result.data.allMarkdownRemark.edges.forEach(({node}) => {
createPage({
path: node.fields.slug,
component: path.resolve('./src/templates/meeting.js'),
context: {slug: node.fields.slug}
});
});
});
};gatsby-browser.js: N/A
gatsby-ssr.js: N/A