diff --git a/gatsby-node.js b/gatsby-node.js index b8db1e4..af36d40 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -3,6 +3,7 @@ const path = require("path") module.exports.createPages = async ({ graphql, actions }) => { const { createPage } = actions const blogTemplate = path.resolve("./src/components/blogPost.js") + const eventTemplate = path.resolve("./src/components/event.js") const result = await graphql(` query { allSanityPost { @@ -13,6 +14,14 @@ module.exports.createPages = async ({ graphql, actions }) => { } } } + allSanityEvent { + nodes { + _id + slug { + current + } + } + } } `) @@ -28,4 +37,17 @@ module.exports.createPages = async ({ graphql, actions }) => { }, }) }) + + const events = result.data.allSanityEvent.nodes + + events.forEach(event => { + const path = `/event/${event.slug.current}` + createPage({ + path, + component: eventTemplate, + context: { + id: event._id, + }, + }) + }) } diff --git a/src/components/event.js b/src/components/event.js index e69de29..5afef0f 100644 --- a/src/components/event.js +++ b/src/components/event.js @@ -0,0 +1,11 @@ +import * as React from "react" + +const Event = () => { + return ( +
+

Ingenting å se her... enda

+
+ ) +} + +export default Event