- 🇳🇱Netherlands Ronald van Belzen
I build such a tool for my employer to help a customer in the transition of existing content to Gutenberg. The existing content contained nested paragraphs. I do not think I am allowed to share the code, but I can make a suggestion for a possible approach.
My approach was creating templates for converting content of content types and paragraph types. The templates contained tokens for referring to content values and entity references and their field values, or media items.
Special fields in the tokens referred to special functions in the engine that was able to convert those templates by replacing the tokens and concatenated them, resulting in a list of Gutenberg blocks that were saved in the body of the to be converted node.
The templates were in fact in most cases already Gutenberg blocks with tokens representing the dynamic content.Templates were saved in configuration, and configuration was also used to indicate which content type(s) needed to undergo transition.
Furthermore, I patched the Gutenberg module function _gutenberg_is_gutenberg_enabled() and added an extra check for whether an individual item (and even individual translation of that content item) of the content_type (for which the Gutenberg experience was switched on and was placed in transition) was already converted (which needed to be tracked in a db table).
This had the added advantage that an editor could convert the content one item and translation at a time, and maybe not convert all the old content and still add new content using the Gutenberg experience at the same time.
During the conversion there needs to be a display for the old content and one for the converted (or new) content, and a switch between the two displays depending on whether the node had been converted of not.
Preparing for transition with such a tool still includes alot of work, but it makes the actual converting of content possible.