web_development:wordpress:gutenberg

Gutenberg

sudo npm install create-guten-block --global
create-guten-block <plugin-name>

or

npx create-guten-block my-block

https://stackoverflow.com/questions/53404030/wordpress-gutenberg-withselect-get-list-of-post-types

https://getwithgutenberg.com/#4-withSelect

const { withSelect } = wp.data;
 
const HammerPriceDisplay = withSelect( ( select, ownProps ) => {
    const { getPrice } = select( 'my-shop' );
    const { currency } = ownProps;
 
    return {
        price: getPrice( 'hammer', currency ),
    };
} )( PriceDisplay );


function PriceDisplay( { price, currency } ) {
    return new Intl.NumberFormat( 'en-US', {
        style: 'currency',
        currency,
    } ).format( price );
}

Example of how to use registerBlockType() to create a custom block in WordPress
https://wp.zacgordon.com/2017/12/28/how-to-use-to-registerblocktype-to-create-blocks-in-wordpress/

  • web_development/wordpress/gutenberg.txt
  • Last modified: 2020/10/09 03:51
  • by jimboobrien