mirror of
https://github.com/Unkn0wnCat/KevinK.dev.js.git
synced 2025-05-09 23:16:57 +02:00
Add Projects-Module
This commit is contained in:
parent
8757b1afb3
commit
688c63910c
13 changed files with 546 additions and 7 deletions
38
gatsby-node.js
Normal file
38
gatsby-node.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
const path = require(`path`);
|
||||
|
||||
exports.createPages = async ({ actions, graphql, reporter }) => {
|
||||
const { createPage } = actions
|
||||
|
||||
const projectTemplate = path.resolve(`src/templates/project.js`)
|
||||
|
||||
const result = await graphql(`
|
||||
query AllPagesQuery {
|
||||
allProjectsJson {
|
||||
nodes {
|
||||
lang
|
||||
urlname
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
`)
|
||||
|
||||
if (result.errors) {
|
||||
reporter.panicOnBuild(`Error while running GraphQL query.`)
|
||||
return
|
||||
}
|
||||
|
||||
result.data.allProjectsJson.nodes.forEach((node) => {
|
||||
console.log("Creating Page: ", `/${node.lang}/projects/${node.urlname}`);
|
||||
|
||||
createPage({
|
||||
path: `/${node.lang}/projects/${node.urlname}`,
|
||||
component: projectTemplate,
|
||||
context: {
|
||||
lang: node.lang,
|
||||
urlname: node.urlname
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue