Gutenberg: Navigation Block: Make it Dynamic

Created on 30 Jul 2019  Â·  3Comments  Â·  Source: WordPress/gutenberg

The navigation menu was initially represented as a collection of static links, but I think that is not appropriate at all for this block. Navigation is inherently a dynamic structure that needs to handle all these requirements:

  • Changes in a site's domain.
  • Updates to permalink structure.
  • Updates to item identity slugs (a page is changed).
  • Dynamically rendering current page (and current sub-menu holding the current page, etc).

I'd suggest converting it to a dynamic block now, where final render is server determined.

[Block] Navigation

Most helpful comment

I was thinking that ideally I’d like the ‘hierarchy’ tree to be encoded in the inner block markup:

<!-- wp:menu -->
    <!-- wp:menu-item {"id": 123} -->
        <!-- wp:menu-item {"id": 123} /-->
    <!-- /wp:menu-item -->
    <!-- wp:menu-item {"id": 123} /-->
<!-- /wp:menu -->

All 3 comments

Apparently there's a WIP PR for this: #16796

I was thinking that ideally I’d like the ‘hierarchy’ tree to be encoded in the inner block markup:

<!-- wp:menu -->
    <!-- wp:menu-item {"id": 123} -->
        <!-- wp:menu-item {"id": 123} /-->
    <!-- /wp:menu-item -->
    <!-- wp:menu-item {"id": 123} /-->
<!-- /wp:menu -->

@noisysocks indeed. It might also be a case to explore saving the internal editor state for that sub-tree without serializing to HTML. (This should not be a blocker, just something to explore.)

Was this page helpful?
0 / 5 - 0 ratings