How do wordpress blocks apply server logic?
-
Take, for instance, the new
navigationhttps://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/navigation. In the database, the block is saved as a post-typewp_navigation, with contents like this:<!-- wp:navigation-link {"label":"Cart","type":"page","id":6,"url":"https://myshop.local/cart/","kind":"post-type"} /--> <!-- wp:navigation-link {"label":"Checkout","type":"page","id":7,"url":"https://myshop.local/checkout/","kind":"post-type"} /--> <!-- wp:navigation-link {"label":"Home","type":"page","id":2,"url":"https://myshop.local/","kind":"post-type"} /--> <!-- wp:navigation-link {"label":"Home","type":"page","id":12684,"url":"https://myshop.local/home/","kind":"post-type"} /--> <!-- wp:navigation-link {"label":"My account","type":"page","id":8,"url":"https://myshop.local/my-account/","kind":"post-type"} /--> <!-- wp:navigation-submenu {"label":"Shop","type":"page","id":5,"url":"https://myshop.local/shop/","kind":"post-type"} --> <!-- wp:navigation-link {"label":"Heren","type":"product_cat","id":52,"url":"https://myshop.local/heren/","kind":"taxonomy"} /--> <!-- wp:navigation-link {"label":"Dames","type":"product_cat","id":16,"url":"https://myshop.local/dames/","kind":"taxonomy"} /--> <!-- /wp:navigation-submenu -->But, it arrives to the browser as server-rendered content, as can be seen here: https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/navigation/index.php#L532.
I always read documentation that told me that rendering was done through Javascript. How is this done in this case? How would I write a block that does this? Is there any documentation about this, or an example piece of code I can learn from?
The topic ‘How do wordpress blocks apply server logic?’ is closed to new replies.