Block Metadata

Block Metadata

Wordpress plugin

Install on Wordpress

App Details

This plugin helps convert WordPress into a manager of our digital content, to publish it in different mediums or platforms: not just the website, but also email, iOS/Android apps, home-assistants (like Amazon Alexa) and others.

It does this by extracting the metadata from all Gutenberg blocks inside of a blog post. Because each Gutenberg block stores its own content and properties, these ones can be extracted as metadata and exported through a JSON object, accessible through a REST API endpoint, to feed any application on any platform.

The plugin makes the following REST API endpoints available:

  • /wp-json/block-metadata/v1/metadata/{POST_ID}: Extract all metadata from all Gutenberg blocks in a blog post with id {POST_ID}, converted to medium-agnostic (eg: removing all non-semantic HTML tags)
  • /wp-json/block-metadata/v1/data/{POST_ID}: Extract all data from all Gutenberg blocks in a blog post with id {POST_ID}, as originally stored in the block by Gutenberg (eg: containing HTML code)

Demonstration:

How does it work?

This plugin is based on the strategy called “Create Once, Publish Everywhere” (also called “COPE”), which reduces the amount of work needed to publish our content into different mediums by establishing a single source of truth for all content.

Having content that works everywhere is not a trivial task, since each medium will have its own requirements. For instance, whereas HTML is valid for printing content for the web, this language is not valid for an iOS/Android app; similarly, we can add classes to our HTML for the web, but these must be converted to styles for email.

The solution is to separate form from content: The presentation and the meaning of the content must be decoupled, and only the meaning is used as the single source of truth. The presentation can then be added in another layer, specific to the selected medium. For instance, given the following piece of HTML code, the <p> is an HTML tag which applies mostly for the web, and attribute class=”align-center” is presentation (placing an element “on the center” makes sense for a screen-based medium, but not for an audio-based one such as Amazon Alexa):

<p class="align-center">Hello world!</p> 

Hence, this piece of content cannot be used as a single source of truth, and it must be converted into a format which separates the meaning from the presentation, such as the following piece of JSON code:

{ content: "Hello world!", placement: "center", type: "paragraph" } 

This piece of code can be used as a single source of truth for content, since from it we can recreate once again the HTML code to use for the web, and procure an appropriate format for other mediums.

Supported Gutenberg blocks

This plugin attempts to extract the metadata for all Gutenberg blocks shipped in WordPress core; support for additional blocks, such as from plugins, can be added through hooks. Not all Gutenberg blocks can be supported (for instance, because they may only work for the web, or only make sense when applied to screen-based mediums, among other reasons).

The following WordPress core blocks are currently not supported:

  • "core/columns"
  • "core/column"
  • "core/cover"
  • "core/html"
  • "core/table"
  • "core/button"
  • "core/media-text"

The following Gutenberg blocks are supported, and this plugin extracts their metadata:

  • "core/paragraph"
  • "core/image"
  • "core-embed/youtube" (all other "core-embed" blocks can also be extracted, but must be implemented through a hook)
  • "core/heading"
  • "core/gallery"
  • "core/list"
  • "core/audio"
  • "core/file"
  • "core/video"
  • "core/code"
  • "core/preformatted"
  • "core/quote"
  • "core/pullquote"
  • "core/verse"

Extracting metadata for additional blocks

We can extend this plugin to extract the metadata for additional blocks, such as those shipped through plugins. To do this, simply add a hook for filter "Leoloso\BlockMetadata\Metadata::blockMeta" (located in function get_block_metadata($block_data) from class Metadata in file block-metadata/src/Metadata.php). The attributes that must be extracted must be decided on a block type by block type basis:

add_filter("Leoloso\BlockMetadata\Metadata::blockMeta", "extract_additional_block_metadata", 10, 3); function extract_additional_block_metadata($blockMeta, $blockName, $block) { if ($blockName == "my-plugin/my-block-name") { return array( "property1" => $block["property1"], "property2" => $block["property2"] ); } return $blockMeta; } 

Further references

Contributing / Reporting issues

Please head over to the project’s GitHub repo for contributing, reporting issues or making suggestions, and others.

Banner image designed by Freepik

Pricing

Starting from $0 per month.

Check Out the Company Branch Flip Cards Widget

By Common Ninja

Company Branch Flip CardsTry For Free!

App Info

Rating

Reviewers

1 reviews

Tags

api
block
content
gutenberg
metadata

Developed By

leoloso

Quick & Easy

Find the Best Wordpress plugins for you

Common Ninja has a large selection of powerful Wordpress plugins that are easy to use, fully customizable, mobile-friendly and rich with features — so be sure to check them out!

Testimonial

Testimonial plugins for Wordpress

Contact Form

Contact Form plugins for Wordpress

Maps

Maps plugins for Wordpress

Translation

Translation plugins for Wordpress

Chat

Chat plugins for Wordpress

Slider

Slider plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Contact

Contact plugins for Wordpress

Galleries

Galleries plugins for Wordpress

SEO

SEO plugins for Wordpress

Forms

Forms plugins for Wordpress

Comments

Comments plugins for Wordpress

Backup

Backup plugins for Wordpress

Privacy

Privacy plugins for Wordpress

Optimize

Optimize plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Comments

Comments plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Video Player

Video Player plugins for Wordpress

popup

popup plugins for Wordpress

SiteMap

SiteMap plugins for Wordpress

Payment

Payment plugins for Wordpress

Coming Soon

Coming Soon plugins for Wordpress

Inventory

Inventory plugins for Wordpress

Testimonials

Testimonials plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Membership

Membership plugins for Wordpress

Forms

Forms plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Sliders

Sliders plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Security

Security plugins for Wordpress

Ads

Ads plugins for Wordpress

Music Player

Music Player plugins for Wordpress

Countdown

Countdown plugins for Wordpress

Email Marketing

Email Marketing plugins for Wordpress

Membership

Membership plugins for Wordpress

Ecommerce

Ecommerce plugins for Wordpress

Customer Support

Customer Support plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Common Ninja Apps

Some of the best Common Ninja plugins for Wordpress

Browse our extensive collection of compatible plugins, and easily embed them on any website, blog, online store, e-commerce platform, or site builder.

Company Branch Flip Cards for Wordpress logo

Company Branch Flip Cards

Display locations with company branch flip cards that help customers find nearby offices, understand key details, and enjoy a smoother overall experience.

Countdown to Download for Wordpress logo

Countdown to Download

Use a countdown to download widget that reveals files after the timer ends, builds anticipation, and guides visitors toward higher engagement.

Restaurant Menu List for Wordpress logo

Restaurant Menu List

Create a clear restaurant menu list that helps visitors explore dishes easily, understand key details, and make confident ordering decisions that support conversions.

Product Blobs for Wordpress logo

Product Blobs

Use product blobs to highlight key items, draw attention to featured products, and guide visitors toward faster and more confident purchase decisions.

Notification Bar for Wordpress logo

Notification Bar

Use a notification bar to alert users, highlight offers, and drive clicks that boost engagement, signups, and conversions.

Facebook Feed for Wordpress logo

Facebook Feed

Show Facebook posts in a live Facebook feed that keeps content fresh, boosts social proof, and helps visitors engage more with your brand.

Image Wall for Wordpress logo

Image Wall

Showcase visuals with an image wall that creates a parallax style gallery, offers smooth scrolling, and presents images in customizable, engaging layouts.

Course Listings for Wordpress logo

Course Listings

Create course listings with a course catalog widget that displays programs clearly, supports easy organization, and helps visitors explore courses effectively.

Tumblr Feed for Wordpress logo

Tumblr Feed

Show Tumblr posts with a Tumblr feed that keeps content fresh, improves navigation, and helps visitors discover more posts.

Reviews Trust Box for Wordpress logo

Reviews Trust Box

Display ratings from multiple platforms in a reviews trust box that builds credibility, social proof, and boosts conversions.

Trust Badges for Wordpress logo

Trust Badges

Show trust badges that highlight security and reliability, build customer confidence, and help visitors feel safe making purchases on your site.

Image Magnifier for Wordpress logo

Image Magnifier

Use an image magnifier to let visitors zoom in on photos, view fine details clearly, and enjoy a more accessible and informative visual experience.

More plugins

plugins You Might Like

Discover Apps By Platform

Discover the best apps for your website

WordPress
Wix
Shopify
Weebly
Webflow
Joomla
PrestaShop
Shift4Shop
WebsiteX5
MODX
Opencart
NopCommerce

Common Ninja Search Engine

The Common Ninja Search Engine platform helps website builders find the best site widgets, apps, plugins, tools, add-ons, and extensions! Compatible with all major website building platforms - big or small - and updated regularly, our Search Engine tool provides you with the business tools your site needs!

Multiple platforms