Skip to content

Commit

Permalink
refactor: migrate to gatsby v2; move some content around
Browse files Browse the repository at this point in the history
  • Loading branch information
DSchau committed Oct 4, 2018
1 parent 1b2b5c9 commit b2ec75f
Show file tree
Hide file tree
Showing 25 changed files with 12,471 additions and 16,740 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ lib/
# Gatsby directories
.cache/
public/

# Mac files
.DS_Store

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,35 @@ module.exports = {
resolve: 'gatsby-source-filesystem',
options: {
name: 'meetings',
path: `${__dirname}/src/meetings`
path: `${__dirname}/content/meetings`
}
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'talks',
path: `${__dirname}/src/talks`
path: `${__dirname}/content/talks`
}
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'speakers',
path: `${__dirname}/src/speakers`
path: `${__dirname}/content/speakers`
}
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'sponsors',
path: `${__dirname}/src/sponsors`
path: `${__dirname}/content/sponsors`
}
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'hosts',
path: `${__dirname}/src/hosts`
path: `${__dirname}/content/hosts`
}
}
]
Expand Down
53 changes: 2 additions & 51 deletions gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,2 @@
const path = require('path');
const {createFilePath} = require('gatsby-source-filesystem');

exports.onCreateNode = ({node, getNode, boundActionCreators}) => {
const {createNodeField} = boundActionCreators;

if ('MarkdownRemark' === node.internal.type && 'File' === getNode(node.parent).internal.type) {
const fileNode = getNode(node.parent);

if (fileNode && 'meetings' === fileNode.sourceInstanceName) {
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 {
frontmatter {
date
}
fields {
slug
}
}
}
}
}
`).then(result => {
result.data.allMarkdownRemark.edges.forEach(({node}) => {
if (!node.fields || !node.fields.slug) return;

createPage({
path: node.fields.slug,
component: path.resolve('./src/templates/meeting.js'),
context: {slug: node.fields.slug}
});
});
});
};
exports.onCreateNode = require('./gatsby/on-create-node');
exports.createPages = require('./gatsby/create-pages');
32 changes: 32 additions & 0 deletions gatsby/create-pages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const path = require('path');

module.exports = ({graphql, actions}) => {
const {createPage} = actions;

return graphql(`
{
allMarkdownRemark {
edges {
node {
frontmatter {
date
}
fields {
slug
}
}
}
}
}
`).then(result => {
result.data.allMarkdownRemark.edges.forEach(({node}) => {
if (!node.fields || !node.fields.slug) return;

createPage({
path: node.fields.slug,
component: path.resolve('./src/templates/meeting.js'),
context: {slug: node.fields.slug}
});
});
});
};
25 changes: 25 additions & 0 deletions gatsby/on-create-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const {createFilePath} = require('gatsby-source-filesystem');

module.exports = ({node, getNode, actions}) => {
const {createNodeField} = actions;

if ('MarkdownRemark' === node.internal.type && 'File' === getNode(node.parent).internal.type) {
const fileNode = getNode(node.parent);

if (fileNode && 'meetings' === fileNode.sourceInstanceName) {
const slug = createFilePath({node, getNode, basePath: 'meetings'});

createNodeField({
node,
name: 'type',
value: fileNode.sourceInstanceName
});

createNodeField({
node,
name: 'slug',
value: slug
});
}
}
};
Loading

0 comments on commit b2ec75f

Please sign in to comment.