Skip to content

Commit

Permalink
Add/navigation blocks post processing after migration from menu items (
Browse files Browse the repository at this point in the history
…#36950)

* add navigation.menuItemsToBlocks filter to postprocess blocks created from menu items

* Add navigation_after_parse_blocks_from_menu_items filter

* Make the filter experimental

* Lint

* Update menu-items-to-blocks.js
  • Loading branch information
adamziel authored and noisysocks committed Dec 13, 2021
1 parent 9798f53 commit 9ea7033
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { sortBy } from 'lodash';
* WordPress dependencies
*/
import { createBlock, parse } from '@wordpress/blocks';
import { applyFilters } from '@wordpress/hooks';

/**
* Convert a flat menu item structure to a nested blocks structure.
Expand All @@ -21,7 +22,12 @@ export default function menuItemsToBlocks( menuItems ) {
}

const menuTree = createDataTree( menuItems );
return mapMenuItemsToBlocks( menuTree );
const blocks = mapMenuItemsToBlocks( menuTree );
return applyFilters(
'blocks.navigation.__unstableMenuItemsToBlocks',
blocks,
menuItems
);
}

/**
Expand Down

0 comments on commit 9ea7033

Please sign in to comment.