Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External link in an image asset #463

Open
spiceee opened this issue May 21, 2023 · 1 comment
Open

External link in an image asset #463

spiceee opened this issue May 21, 2023 · 1 comment

Comments

@spiceee
Copy link

spiceee commented May 21, 2023

Hi,

I'm working on a migration from another vendor to Contenful and using rich-text-from-markdown. I've bumped into a problem saving an entry that is an image asset with a hyperlink to an external URL.

That node gets converted to:

{
	"nodeType": "paragraph",
	"content": [
		{
			"nodeType": "hyperlink",
			"data": {
				"uri": "https://example.com"
			},
			"content": [
				{
					"nodeType": "embedded-asset-block",
					"content": [],
					"data": {
						"target": {
							"sys": {
								"type": "Link",
								"linkType": "Asset",
								"id": "YtjKJ0vIXHa1z1xsIvBbM"
							}
						}
					}
				}
			]
		}
	],
	"data": {}
},

But Contentful throws this error:

InvalidEntry: {
  "status": 422,
  "statusText": "Unprocessable Entity",
  "message": "Validation error",
  "details": {
    "errors": [
      {
        "name": "in",
        "details": "Value must be one of expected values",
        "path": [
          "fields",
          "body",
          "en-US",
          "content",
          6,
          "content",
          0,
          "content",
          0,
          "nodeType"
        ],
        "value": "embedded-asset-block",
        "expected": [
          "text"
        ]
      }
    ]
  },

I've also tried creating an entry in the Contentful rich text component selecting an image asset, and adding a link to it, but although it apparently lets me do that, the hyperlink doesn't get added to the embedded asset when I fetch it via the API.

Are linked image assets not allowed?

Thanks!

@ashleytwo
Copy link

I'm having the same problem (or perhaps question depending on how you look at it). From the error message its obviously got some kind of hierarchy as to what can go in where (in this case, embedded-asset-block can't go in a paragraph) but I can't find any information as to what it does and doesn't allow without brute force trial and error.

If I remove the anchor from the original source it then changes the nodeType from paragraph to embedded-asset-block, but then obviously isn't linking the image like I wanted anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants