How to use the gatsby-core-utils.urlResolve function in gatsby-core-utils

To help you get started, we’ve selected a few gatsby-core-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github system-ui / theme-ui / packages / gatsby-theme-code-recipes / gatsby-node.js View on Github external
getNode,
  createNodeId,
  loadNodeContent,
  createContentDigest,
}) => {
  if (node.internal.type !== 'Mdx') return
  const parent = getNode(node.parent)
  if (parent.sourceInstanceName !== source) return

  const id = createNodeId(`${node.id} >>> MdxRecipe`)
  const filepath = createFilePath({
    node: parent,
    getNode,
    basePath: source,
  })
  const slug = urlResolve(basePath, filepath)

  await actions.createNode({
    id,
    name: node.frontmatter.name || filepath,
    slug,
    parent: node.id,
    children: [],
    internal: {
      type: 'MdxRecipe',
      contentDigest: createContentDigest(node.rawBody),
    },
    content: node.rawBody,
    description: 'Code recipes',
  })

  actions.createParentChildLink({

gatsby-core-utils

A collection of gatsby utils used in different gatsby packages

MIT
Latest version published 4 months ago

Package Health Score

91 / 100
Full package analysis