4.0.0 • Published 9 months ago

@lipemat/js-boilerplate-gutenberg v4.0.0

Weekly downloads
66
License
MIT
Repository
github
Last release
9 months ago

WordPress/Gutenberg extension for @lipemat/js-boilerplate for zero configuration Gutenberg support.

Installation

yarn add @lipemat/js-boilerplate-gutenberg

TypeScript

This package is completely built in TypeScript and supports native JavaScript or TypeScript applications.

Gutenberg definitions

Due to requirements created by Yarn PNP, the Gutenberg definitions have been moved to an external package and will be maintained there.

If you are not using PNP, the definitions are included in this package's package.json so there are no additional steps to use them.

If you are using PNP you may add the definitions to your package.json like so.

"dependencies": {
    "@types/lipemat__js-boilerplate": "lipemat/types-js-boilerplate#semver:^1.0.0"
  }

Application Passwords

As of WordPress 5.6, support for application passwords is available on all SSL sites. Prior to 5.6 application passwords may be enabled via the application passwords plugin.

Helper functions are available for interacting with the application passwords system.

import {setRootURL, wpapi, enableApplicationPassword, getAuthorizationUrl} from '@lipemat/js-boilerplate-gutenberg';

// Point the REST API at an external site.
setRootURL( 'https://starting-point.dev/wp-json/' );

// Retrieve the URL to redirect your users to for authorization.
const URL = await getAuthorizationUrl({
    app_name: 'Test Application'
});

// Add an application password to all subsequent requests.
enableApplicationPassword( 'test', 'nnXX zPX6 5Fqc 21tG zLH0 Rtep' );

// Request will be authenticated.
const post = await wp.posts().create( {
	title: 'Test Post',
} );

Hot Module Reloading For Blocks and Plugins

Helper methods exists for automatically loading block or plugin files based on a REGEX filter as well as handling the various register and unregister requirements to make HMR work.

Loaded modules are expected to export: 1. name: Name of plugin or block (id format). 2. settings: Either a plugin or block's settings. 3. exclude: Exclude plugin or block from the current context.

import {autoloadBlocks, autoloadPlugins} from '@lipemat/js-boilerplate-gutenberg';

/**
 * Use our custom autoloader to automatically require,
 * register and add HMR support to Gutenberg related items.
 *
 * Will load from specified directory recursively.
 */
export default () => {
	// Load all blocks
	autoloadBlocks( () => require.context( './blocks', true, /block\.tsx$/ ), module );

	// Load all meta boxes
	autoloadPlugins( () => require.context( './meta-boxes', true, /index\.tsx$/ ), module );

}

Hooks

usePostMeta

usePostMeta is used to interact with the current post's meta from sidebars or meta boxes within Gutenberg.

Will return the current meta state as well as the original meta state before any changes were made.

You may work with a single meta key like so:

const [value, updateValue, previous] = usePostMeta( 'custom-meta-key' );

Or by default work with the whole meta object:

const [values, updateValues, previous] = usePostMeta();

useTerms

useTerms is used to interact with the current post's terms from sidebars or meta boxes within Gutenberg.

Will return the current terms state as well as the original terms state before any changes were made.

const [terms, updateTerms, previous] = useTerms( 'category' );
4.0.0

9 months ago

4.0.0-beta.9

9 months ago

4.0.0-beta.8

9 months ago

3.4.3

10 months ago

4.0.0-beta.7

10 months ago

4.0.0-beta.6

10 months ago

4.0.0-beta.5

10 months ago

4.0.0-beta.4

10 months ago

4.0.0-beta.3

10 months ago

4.0.0-beta.2

10 months ago

4.0.0-beta.1

10 months ago

3.4.2

1 year ago

3.4.1

1 year ago

3.3.3

1 year ago

3.3.2

1 year ago

3.2.1

2 years ago

3.2.0

2 years ago

3.3.1

2 years ago

3.2.0-beta.1

2 years ago

3.2.1-beta.2

2 years ago

3.2.1-beta.1

2 years ago

3.0.0

2 years ago

3.1.2

2 years ago

3.0.0-beta.1

2 years ago

3.0.0-beta.2

2 years ago

2.11.0

2 years ago

2.10.1

3 years ago

2.9.7

3 years ago

2.10.0

3 years ago

2.9.2

3 years ago

2.9.1

3 years ago

2.9.4

3 years ago

2.9.3

3 years ago

2.9.6

3 years ago

2.9.5

3 years ago

2.9.0

3 years ago

2.8.0

3 years ago

2.7.0

3 years ago

2.6.1

3 years ago

2.6.0

4 years ago

2.6.3

3 years ago

2.6.3-beta.1

3 years ago

2.6.2

3 years ago

2.6.1-beta.1

3 years ago

2.6.1-beta.2

3 years ago

2.6.5

3 years ago

2.6.4

3 years ago

2.5.1

4 years ago

2.5.0

4 years ago

2.4.1

4 years ago

2.4.0

4 years ago

2.3.2

4 years ago

2.3.1

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

1.4.4

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

2.0.1

4 years ago

2.0.0

5 years ago

2.0.0-beta.6

5 years ago

2.0.0-beta.5

5 years ago

2.0.0-beta.4

5 years ago

2.0.0-beta.3

5 years ago

2.0.0-beta-2

5 years ago

2.0.0-beta-1

5 years ago

1.4.0

5 years ago

1.3.7

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

1.1.0-beta

6 years ago

1.0.1-beta

6 years ago

1.0.0-beta

6 years ago