mirror of
https://github.com/oceanprotocol/market.git
synced 2024-11-15 09:44:53 +01:00
43 lines
935 B
JavaScript
43 lines
935 B
JavaScript
|
const path = require('path')
|
||
|
|
||
|
async function createMarkdownPages(graphql, actions) {
|
||
|
const { createPage } = actions
|
||
|
|
||
|
const markdownPageTemplate = path.resolve(
|
||
|
'./src/components/templates/PageMarkdown.tsx'
|
||
|
)
|
||
|
// Grab all markdown files with a frontmatter title defined
|
||
|
const markdownResult = await graphql(`
|
||
|
{
|
||
|
allMarkdownRemark(filter: { frontmatter: { title: { ne: "" } } }) {
|
||
|
edges {
|
||
|
node {
|
||
|
fields {
|
||
|
slug
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
`)
|
||
|
|
||
|
if (markdownResult.errors) {
|
||
|
throw markdownResult.errors
|
||
|
}
|
||
|
|
||
|
// Create markdown pages.
|
||
|
const markdownPages = markdownResult.data.allMarkdownRemark.edges
|
||
|
|
||
|
markdownPages.forEach((page) => {
|
||
|
createPage({
|
||
|
path: page.node.fields.slug,
|
||
|
component: markdownPageTemplate,
|
||
|
context: {
|
||
|
slug: page.node.fields.slug
|
||
|
}
|
||
|
})
|
||
|
})
|
||
|
}
|
||
|
|
||
|
module.exports = createMarkdownPages
|