Skip to content

How to use with Sanity Cloudinary Plugin #215

Answered by raae
raae asked this question in Q&A
Discussion options

You must be logged in to vote

Sanity creates nodes with fields of type SanityCloudinaryAsset when you pick an image from Cloudinary. Unfortunately it does not have the shape require by gatsby-transformer-cloudinary.

To get around that you may create nodes with the correct shape.

Let say we have the Gatsby node of type SanityArticle with a field cover of type SanityCloudinaryAsset

// File: gatsby-node.js

exports.onCreateNode = async (gatsbyUtils) => {
  const { node, actions, createNodeId, createContentDigest } = gatsbyUtils
  const { createNode } = actions

  if (node.internal.type === "SanityArticle") {
    // Create the correct data shape
    const cloudinaryAssetData = {
      cloudName: "cloud-name", // use your …

Replies: 1 comment

Comment options

raae
Dec 1, 2022
Collaborator Author

You must be logged in to vote
0 replies
Answer selected by raae
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant