Ollie Block Academy

Storing Data with Blocks

Registering an attribute

All attributes must be defined in block.json before they can be used in code. The attributes section contains key-value pairs where keys are attribute names and values are configuration objects.

Every attribute requires a type property, with rich-text being appropriate for content that uses the RichText component. Static blocks also need source and selector properties to specify where data is stored in HTML.

The selector uses CSS selector syntax to identify HTML elements containing attribute data. For single paragraph blocks, the selector “p” targets the paragraph tag containing the rich text content.

Back to: Ollie Block Academy > Storing Data with Blocks