Notion update: databasePage Error message when using Rich Text,texts is not iterable
Code node
const rawText = $input.first().json.choices[0].message.content;
const matches = rawText.match(/(\d+).\s*[^::]+[::]\s*[^0-9]+(?=\d+.|$)/g);
const richTexts = matches.map(text => ({
type: ‘text’,
text: { content: text.trim() },
annotations: {
bold: false,
italic: false,
strikethrough: false,
underline: false,
code: false,
color: ‘default’
}
}));
const result = matches.map(text => text.trim()).join(‘\n’);
return [{ json: { texts: richTexts, result } }];
Output content
`[
{
“texts”:
[
{
“type”:
“text”,
“text”:
{
“content”:
“1. 英语(English): How can high-quality mineral water be mass-produced? A comprehensive process analysis from water selection to bottling.”
},
“annotations”:
{
“bold”:
false,
“italic”:
false,
“strikethrough”:
false,
“underline”:
false,
“code”:
false,
“color”:
“default”
}
},
{
“type”:
“text”,
“text”:
{
“content”:
“2. 中文繁体(Traditional Chinese): 如何大量製造高品質礦泉水?從選水到灌裝的完整流程解析。”
},
“annotations”:
{
“bold”:
false,
“italic”:
false,
“strikethrough”:
false,
“underline”:
false,
“code”:
false,
“color”:
“default”
}
},
{
“type”:
“text”,
“text”:
{
“content”:
“3. 印地语(Hindi): उच्च गुणवत्ता वाली खनिज जल को बड़े पैमाने पर कैसे उत्पादित करें? पानी के चयन से बोतलबंदी तक पूरी प्रक्रिया का विश्लेषण।”
},
“annotations”:
{
“bold”:
false,
“italic”:
false,
“strikethrough”:
false,
“underline”:
false,
“code”:
false,
“color”:
“default”
}
},
{
“type”:
“text”,
“text”:
{
“content”:
“4. 西班牙语(Spanish): ¿Cómo producir en masa agua mineral de alta calidad?”
},
“annotations”:
{
“bold”:
false,
“italic”:
false,
“strikethrough”:
false,
“underline”:
false,
“code”:
false,
“color”:
“default”
}
}
],
“result”:
“1. 英语(English): How can high-quality mineral water be mass-produced? A comprehensive process analysis from water selection to bottling.\n2. 中文繁体(Traditional Chinese): 如何大量製造高品質礦泉水?從選水到灌裝的完整流程解析。\n3. 印地语(Hindi): उच्च गुणवत्ता वाली खनिज जल को बड़े पैमाने पर कैसे उत्पादित करें? पानी के चयन से बोतलबंदी तक पूरी प्रक्रिया का विश्लेषण।\n4. 西班牙语(Spanish): ¿Cómo producir en masa agua mineral de alta calidad?”
}
