async function transformPageBody(page, locale) {
    const copy = page.fields.body[locale]
    return await richTextFromMarkdown(copy, async mdNode => {
      if (mdNode.type !== `image`) return null

      // Create and asset and publish it
      const space = await managementClient.getSpace(spaceId)
      // Unfortunately, we can't pull the environment id from the context
      const environment = await space.getEnvironment(`rich-text-migration`)

      let asset = await environment.createAsset({
        fields: {
          title: {
            'de-DE': mdNode.title ? mdNode.title + locale : mdNode.alt + locale,
          },
          file: {
            'de-DE': {
              contentType: getContentType(mdNode.url),
              fileName: getFileName(mdNode.url) + locale,
              upload: `https:${mdNode.url}`,
            },
          },
        },
      })
      asset = await asset.processForAllLocales({
        processingCheckWait: 4000,
      })
      asset = await asset.publish()
      console.log(`published asset's id is ${asset.sys.id}`)
      return {
        nodeType: `embedded-asset-block`,
        content: [],
        data: {
          target: {
            sys: {
              type: `Link`,
              linkType: `Asset`,
              id: asset.sys.id,
            },
          },
        },
      }
    })
  }
// Return Rich Text instead of Markdown
Return Rich Text instead of Markdown
Return Rich Text instead of Markdown
async function transformPageBody(page, locale) {
    const copy = page.fields.body[locale]
    return await richTextFromMarkdown(copy, async mdNode => {
      if (mdNode.type !== `image`) return null
      const space = await managementClient.getSpace(spaceId)
      const environment = await space.getEnvironment(`rich-text-migration`)
      let asset = await environment.createAsset({
        fields: {
          title: {
            'de-DE': mdNode.title ? mdNode.title + locale : mdNode.alt + locale,
          },
          file: {
            'de-DE': {
              contentType: getContentType(mdNode.url),
              fileName: getFileName(mdNode.url) + locale,
              upload: `https:${mdNode.url}`,
            },
          },
        },
      })
      asset = await asset.processForAllLocales({
        processingCheckWait: 4000,
      })
      asset = await asset.publish()
      console.log(`published asset's id is ${asset.sys.id}`)
      return {
        nodeType: `embedded-asset-block`,
        content: [],
        data: {
          target: {
            sys: {
              type: `Link`,
              linkType: `Asset`,
              id: asset.sys.id,
            },
          },
        },
      }
    })
  }
async function transformPageBody ( page , locale ) { const copy = page . fields . body [ locale ] return await richTextFromMarkdown ( copy , async mdNode => { if ( mdNode . type !== ` ` ) return null const space = await managementClient . getSpace ( spaceId ) const environment = await space . getEnvironment ( ` ` ) let asset = await environment . createAsset ( { fields : { title : { 'de-DE' : mdNode . title ? mdNode . title + locale : mdNode . alt + locale , } , file : { 'de-DE' : { contentType : getContentType ( mdNode . url ) , fileName : getFileName ( mdNode . url ) + locale , upload : ` ${ mdNode . url } ` , } , } , } , } ) asset = await asset . processForAllLocales ( { processingCheckWait : 4000 , } ) asset = await asset . publish ( ) console . log ( ` ${ asset . sys . id } ` ) return { nodeType : ` ` , content : [ ] , data : { target : { sys : { type : ` ` , linkType : ` ` , id : asset . sys . id , } , } , } , } } ) }
Return Rich Text instead of Markdown
Return Rich Text instead of Markdown
// Create and asset and publish it // Unfortunately, we can't pull the environment id from the context