Webiny features a module that allows you to build navigational menus.
Each menu has a
Description and menu items.
To render a menu on your site, you need to do that as part of your theme implementation. Webiny exposes a
Menu component that is part of
@webiny/app-page-builder library. Using that component you can retrieve any menu that's defined in your system and then render it using a provided component.
A simple example would look like this:
The above code retrieves the requested menu using the
slug prop and then renders the menu using the
A sample implementation of
MenuRenderComponent would look something like so:
Note: You might notice a small optimization inside the
getLinkfunction. The function uses the
react-router-domlibrary to handle the clicks on internal links. If the link is not an internal link than a standard
anchorelement is used.