0.3.0 • Published 3 years ago

headless-blocks v0.3.0

Weekly downloads
8
License
MIT
Repository
-
Last release
3 years ago

Headless Blocks

Install

npm install headless-blocks

Use

import React from 'react'
import {HeadlessBlocks} from 'headless-blocks';

// Example of a custom component you can make to be rendered for any block. 
import {MyCoreParagraph} from './CoreParagraph.js';
import {MyCoreHeading} from './CoreHeading.js';

export default () => {
	return (
		<HeadlessBlocks 
			postContent={ '<!-- wp:paragraph --><p>I am the raw HTML content generated by the WordPress Block Editor.</p><!-- /wp:paragraph -->' }
			blockComponents={ {
				'core/paragraph': MyCoreParagraph,
				'core/heading': MyCoreHeading
			} }
		/>
	)
}

Fields

PropertyTypeDescription
postContentstringThe raw Gutenberg Block Editor content, including the HTML comment separators.
blockComponentsobjectAn object containing the block name and corresponding components to use for specific blocks. Set the key to match the block name, as defined in the first paramater of registerBlockType when the block was registered with the Block Editor.

Contributors

johnstonphilip, ryankienstra