Function: isBlockByName()
isBlockByName(
node,name):boolean
Defined in: packages/core/src/dom/index.ts:334
Tests a node by block name. This requires the Headless WP Plugin to be installed.
The Headless WP Plugin will append data-wp-block-name and data-wp-block to every block,
this function relies on those attributes to determine if the node is a block.
This function expects to be used with DOMNode objects from html-react-parser, which is
the underlying parser used by BlocksRenderer.
Usage
import { isBlockByName } from '@headstartwp/core';
<BlocksRenderer html={html}>
<MyCustomBlock
test={(node) => isBlock(node, 'core/paragraph')}
/>
</BlocksRenderer>
Parameters
node
The node to test
name
string
The block name
Returns
boolean
true if the node passes the test