WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.57k stars 4.22k forks source link

Backend conversion of classic content to Gutenberg blocks #15894

Closed iuravic closed 5 years ago

iuravic commented 5 years ago

Hello!

I would kindly ask for advice on how to best implement the conversion of classic/pre-Gutenberg post content to blocks as a backend functionality. The need arises from multiple websites which need their old content converted to blocks (it is a significant number of sites, some with ~50,000 posts in history).

As far as I researched (from the Gutenberg Issues, PRs, and WP Code Reference), this functionality is currently not yet available in the backend. So I would kindly appreciate any advices and suggestions on how to provide/implement this functionality via a backend endpoint/function.

The one current idea so far comes from this comment in Convert to blocks in PHP #13163 suggesting to "... use a node script running jsdom and use the wp.blocks.rawHandler function ...".

For now, I’ve only triggered the conversion of the content in the frontend programmatically, in a local installation of the Gutenberg in a VVV site -- very crudely, what I did was something in the lines of: select("core/editor") > getBlocks() > dispatch().replaceBlocks).

swissspidy commented 5 years ago

As far as I can tell, the latest comment on #13163 is still accurate. What differentiates your ticket from that issue?

iuravic commented 5 years ago

The two Issues address the same point; just that since Issue #13163 was closed, with this new one I was simply hoping for an up-to-date confirmation that to use node was still the recommended path (to implement the conversion in the backend).

And so thank you for confirming this, Pascal! I'll proceed with the suggested method.

danieliser commented 2 months ago

Why are these all closed, and after 5 years still no method to solve this, yet they still expect everybody to happily jump on the Gutenberg train like these major gaps in coverage don't exist.