Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/threemammals/gutenberg-to-react

Parse Wordpress Gutenberg post_content to a React tree
https://github.com/threemammals/gutenberg-to-react

gutenberg react reactjs wordpress

Last synced: 10 days ago
JSON representation

Parse Wordpress Gutenberg post_content to a React tree

Awesome Lists containing this project

README

        

# Gutenberg to React

This package allows you to convert Wordpress Gutenbergs post_content field on the post object to a ReactJs tree.

[![CircleCI](https://circleci.com/gh/ThreeMammals/gutenberg-to-react/tree/master.svg?style=svg)](https://circleci.com/gh/ThreeMammals/gutenberg-to-react/tree/master)

## Why

Madness.

## Install

`npm install @threemammals/gutenberg-to-react`

## How To

```javascript
const { gutenbergToReact } = require('@threemammals/gutenberg-to-react');

// example of Wordpress Gutenberg post_content from the post object
const input = '\n

text

\n';

// parse to ReactJs tree
const result = gutenbergToReact(input);

// check out your ReactJs tree?!?!?
console.log(result);
[
{
type: 'core/paragraph',
ref: null,
'$$typeof': Symbol(react.element),
props: { style: {}, className: null, children: [Array] }
}
]
```