-
Notifications
You must be signed in to change notification settings - Fork 0
Getting started
Mathieu Maes edited this page May 15, 2018
·
1 revision
Make sure you have installed the Core package:
npm install @node-menu/core
After installation, you should start by defining a menu:
const { Menu, MenuItem } = require("@node-menu/core")
const topMenu = new Menu("topMenu", {
children: [
{
label: "Home",
href: "/",
},
{
label: "Our team",
href: "/team",
children: [
{
label: "Sales team",
href: "/team/sales",
}
]
},
{
label: "Services",
href: "/services",
}
]
});
// You can also add menu's by calling Menu::addChild
topMenu.addChild("Contact us", {
href: "/contact"
});
// Or, create your MenuItem instance yourself
const jobsMenu = new MenuItem("Jobs", { href: "/jobs" });
topMenu.addChild(jobsMenu);
// This works in an infinite number of levels
const applyMenu = jobsMenu.addChild("Apply now", { href: "/jobs/application" });Note: The root node of your menu is an instance of Menu,
children and other decendants are instances of MenuItem.