Hi,
Please note that the nodes I’m talking about below are not n8n nodes.
They are arrays in the JSON data I’m manipulating.
My goal is to add a Table of Contents (ToC) at the beginning of a very long draft blog post on the Wix platform to improve navigation within the blog post (jump to specific sections).
My technical challenge: merging the initial draft blog post’s content with the ToC content I’ve generated (JSON).
So far I’ve successfully retrieved the post’s as JSON from their REST API, extracted the richContent property, filtered it to keep only HTML header data (H2, H3, …) and transformed these headers to a new JSON that contains the ToC.
The richContent property contains an array of “nodes” used to describe the content: paragraphs of text, images, links, headers, …
I’ve generated the ToC as a JSON that contains an array of “nodes” using the same format.
Describe the problem/error/question
Now, I just need to insert the ToC “nodes” at the beginning of the initial richContent “nodes” in order to update the draft post’s content so I can finally update it on the Wix server.
Say for example that my richContent initial “nodes” array contains 150 nodes. I extract 7 headers from it and generate 7 ToC nodes. I now need to add these 7 to the richContent.nodes property that will contain 157 items as a result (the first 7 being the ToC nodes).
I’ve made attempts with the Code block and the Item Lists block (Operation: Concatenate) but couldn’t figure it out.
At the end of the process, I need the draft blog post JSON object (retrieved at the beginning of the workflow) to be updated so that its richContent.nodes property contains the ToC nodes + all the initial nodes. So I can finally call the Wix REST API’s UpdateDraftPost endpoint and include the updated draftPost object.
What is the error message (if any)?
None.
Please share your workflow
Share the output returned by the last node
Information on your n8n setup
- n8n version: 1.17.1
- Database (default: SQLite): default
- n8n EXECUTIONS_PROCESS setting (default: own, main): default
- Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
- Operating system: Windows 11