gatsby markdown to html code example

Example: gatsby markdown blog

Copygatsby-node.js: copy code to clipboardexports.createPages = async ({ actions, graphql, reporter }) => {  const { createPage } = actions  const blogPostTemplate = require.resolve(`./src/templates/blogTemplate.js`)  const result = await graphql(`    {      allMarkdownRemark(        sort: { order: DESC, fields: [frontmatter___date] }        limit: 1000      ) {        edges {          node {            frontmatter {              slug            }          }        }      }    }  `)  // Handle errors  if (result.errors) {    reporter.panicOnBuild(`Error while running GraphQL query.`)    return  }  result.data.allMarkdownRemark.edges.forEach(({ node }) => {    createPage({      path: node.frontmatter.slug,      component: blogPostTemplate,      context: {        // additional data can be passed via context        slug: node.frontmatter.slug,      },    })  })}

Tags:

Misc Example