soames-gatsby-theme
Version:
A customizable Gatsby theme for personal websites using WordPress as a headless CMS.
35 lines (34 loc) • 2.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const gatsby_1 = require("gatsby");
const HeaderMenu = () => {
const data = (0, gatsby_1.useStaticQuery)((0, gatsby_1.graphql) `
query WpHeaderMenu {
wpMenu(name: { eq: "soames-header-menu" }) {
id
name
menuItems {
nodes {
id
label
parentDatabaseId
path
uri
order
childItems {
nodes {
id
label
uri
order
}
}
}
}
}
}
`);
return ((0, jsx_runtime_1.jsx)("div", { className: "collapse navbar-collapse", id: "navbarSupportedContent", children: (0, jsx_runtime_1.jsx)("ul", { className: "navbar-nav nav-dropdown nav-right", "data-app-modern-menu": "true", children: data.wpMenu.menuItems.nodes.map((item) => item.path !== "/home/" && item.parentDatabaseId === 0 ? (item.childItems.nodes.length === 0 ? ((0, jsx_runtime_1.jsx)("li", { className: "nav-item", children: item.uri.includes("http") ? ((0, jsx_runtime_1.jsx)("a", { className: "nav-link link text-white display-4", href: item.uri, target: "_blank", rel: "noreferrer", children: item.label })) : ((0, jsx_runtime_1.jsx)(gatsby_1.Link, { to: item.uri, className: "nav-link link text-white display-4", children: item.label })) }, item.id)) : ((0, jsx_runtime_1.jsxs)("li", { className: "nav-item dropdown", children: [(0, jsx_runtime_1.jsx)("a", { className: "nav-link link text-white dropdown-toggle display-4", href: item.uri, "data-toggle": "dropdown-submenu", "aria-expanded": "false", children: item.label }), (0, jsx_runtime_1.jsx)("div", { className: "dropdown-menu", children: (0, jsx_runtime_1.jsx)("ul", { className: "navbar-nav nav-dropdown nav-right", children: item.childItems.nodes.map((childItem) => ((0, jsx_runtime_1.jsx)("li", { children: childItem.uri.includes("http") ? ((0, jsx_runtime_1.jsxs)("a", { className: "text-white dropdown-item display-4", target: "_blank", rel: "noreferrer", href: childItem.uri, children: [childItem.label, (0, jsx_runtime_1.jsx)("br", {})] })) : ((0, jsx_runtime_1.jsx)(gatsby_1.Link, { to: childItem.uri, className: "text-white dropdown-item display-4", children: childItem.label })) }, childItem.id))) }) })] }, item.id))) : null) }) }));
};
exports.default = HeaderMenu;