最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

block editor - Gutenberg : in the backend, I just want to store a JSON object

programmeradmin5浏览0评论

I'm starting to learn Gutenberg blocks.

I want to create a Gutenberg "track" block as part of a larger music "app" i'm working on.

The whole app will rely on a standard named JSPF, which is a JSON object crafted to define a playlist and its tracks.

So a basic JSPF track looks like this:

{
  "title"         : "Track title",
  "creator"       : "Artist name",
  "album"         : "Album name"
}

I want to build a Gutenberg "track" block that could deal with such an object.
When editing a block, I don't want it to store the HTML that will be rendered, I just want to store the JSPF track object.

For instance, the Gutenberg video block stores data like this

<!-- wp:video -->
<figure class="wp-block-video"><video controls src=".mp4"></video></figure>
<!-- /wp:video -->

I don't need to store the HTML output like that block. I just need to store the JSON object and will use a javascript (React) component when I need to display it.

How should I tacke this ?

Thanks a lot !

发布评论

评论列表(0)

  1. 暂无评论