I’m currently migrating our blog. I am converting html → markdown and then using the rich-text-from-markdown
package to convert to rich text. however, I continue to get the following error when converting a simple unordered list. here is the error I’m getting: (sorry code ticks make this look worse)
InvalidEntry: {
“status”: 422,
“statusText”: “Unprocessable Entity”,
“message”: “Validation error”,
“details”: {
“errors”: [
{
“name”: “in”,
“details”: “Value must be one of expected values”,
“path”: [
“fields”,
“content”,
“en-US”,
“content”,
14,
“content”,
0,
“nodeType”
],
“value”: “ordered-list”,
“expected”: [
“paragraph”
]
}
]
},
here is an example of the json being used during createEntry
:
content: [
{
“nodeType”: “unordered-list”,
“content”: [
{
“nodeType”: “list-item”,
“content”: [
{
“nodeType”: “paragraph”,
“content”: [
{
“nodeType”: “text”,
“value”: "They use ",
“marks”: ,
“data”: {}
},
{
“nodeType”: “text”,
“value”: “new”,
“marks”: [
{
“type”: “italic”
}
],
“data”: {}
}, … more json
Here is the function call for createEntry
:
const created = await client.createEntry(“blogPost”, {
fields: {
title: {
[CONTENTFUL_LOCALE]: post.title,
},
slug: {
[CONTENTFUL_LOCALE]: post.slug,
},
seo: {
[CONTENTFUL_LOCALE]: {
sys: { type: “Link”, linkType: “Entry”, id: post.seoId },
},
},
author: {
[CONTENTFUL_LOCALE]: [
{
sys: {
type: “Link”,
linkType: “Entry”,
id: post.authorId,
},
},
],
},
categories: {
[CONTENTFUL_LOCALE]: [
{ sys: { type: “Link”, linkType: “Entry”, id: post.categoryId } },
],
},
content: {
[CONTENTFUL_LOCALE]: convertedContent
,
},
featuredImage: post.featuredImage,
},
});
convertedContent
is the output from richTextFromMarkdown
and is just standard markdown from Turndown with no options other than using atx
for headingStyle. I’m not sure where the real problem lies. With my code or if this is a bug since the rich text nodes are coming from the Contentful package.