Show event types

This commit is contained in:
ponas committed 2019-02-22 02:39:00 +01:00
1 parent eacec6e824
commit 8cf3db32af
4 files changed
+168 -46

No files matched your search

+39 -1
View File
@@ -158,6 +158,43 @@ exports.createPages = ({ actions, graphql }) => {
component: programTemplate,
})
})
.then(() => {
return graphql(`
{
allWordpressWpEventType(filter: { count: { gt: 0 } }) {
edges {
node {
id
name
slug
fields {
link
}
}
}
}
}
`)
})
.then(result => {
if (result.errors) {
result.errors.forEach(e => console.error(e.toString()))
return Promise.reject(result.errors)
}
const eventTypeTemplate = path.resolve(`./src/templates/event-type.js`)
_.each(result.data.allWordpressWpEventType.edges, ({ node: event_type }) => {
createPage({
path: event_type.fields.link,
component: eventTypeTemplate,
context: {
name: event_type.name,
slug: event_type.slug,
},
})
})
})
.then(() => {
return graphql(`
{
@@ -276,7 +313,8 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
}
if ((node.internal.type === 'wordpress__POST') ||
(node.internal.type === 'wordpress__wp_events')) {
(node.internal.type === 'wordpress__wp_events') ||
(node.internal.type === 'wordpress__wp_event_type')) {
const link = new URL(node.link).pathname
createNodeField({
node,