stackbit / gatsby-plugin-menus

Gatsby plugin for site menus
MIT License
9 stars 6 forks source link

How to nest menus? #8

Closed richardrobberse closed 4 years ago

richardrobberse commented 4 years ago

Hi guys, I've followed the readme but it's not clear how to nest menus. Could you please elaborate on the frontmatter I have to use in order to nest a menu?

Thanks in advance!

smnh commented 4 years ago

Hi @richardrobberse,

To create parent-child relationships between menus, you need add identifier property to a menu item that you want to use as a parent menu. Then use the value of that identifier as the menu name of child menu item.

---
title: Foo
menus:
  main: 
    identifier: sub_menu # identifier for this menu item to be used by child menu item
    title: Go to Foo
    weight: 1
---
---
title: Bar
menus:
  sub_menu: # the identifier of the parent menu
    title: Go to Bar
    weight: 1
---
richardrobberse commented 4 years ago

Thanks a lot @smnh, I think I've tried something like this but I'll give it another try somewhere today. I think this would be a valuable addition to the docs.