Created
June 4, 2022 09:55
-
-
Save openscript/d56a810c1fe9b2639ba0b112e217f8ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { GatsbyNode } from 'gatsby'; | |
import { resolve } from 'path'; | |
export const createPages: GatsbyNode['createPages'] = async args => { | |
const { actions, graphql } = args; | |
const { createPage } = actions; | |
const allPages = await graphql<Queries.AllGenericPagesQuery>(` | |
query AllGenericPages { | |
allMdx(filter: { fields: { kind: { eq: "pages" } } }) { | |
edges { | |
node { | |
id | |
fields { | |
path | |
translations { | |
locale | |
path | |
} | |
} | |
} | |
} | |
} | |
} | |
`); | |
allPages.data?.allMdx.edges.forEach(p => { | |
if (p.node.fields && p.node.fields.path) { | |
createPage({ | |
component: resolve('./src/templates/GenericPage.tsx'), | |
context: { id: p.node.id, translations: p.node.fields.translations }, | |
path: p.node.fields.path, | |
}); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment