Newer
Older
import { Link } from "@onegeo/gatsby-theme-onegeo"
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const { className, name } = props
const data = useStaticQuery(graphql`
fragment MenuItem on DirectusData_menus {
name
url
page {
slug
}
}
fragment MenusRecursive on DirectusData_menus {
children {
...MenuItem
children {
...MenuItem
children {
...MenuItem
}
}
}
}
query {
directus {
menus(
filter: {
status: { _eq: "published" }
}
) {
name
...MenusRecursive
}
}
}
`)
const menuContent = data.directus.menus
const menu = menuContent.find(
(menu:any) => name?.toLowerCase() === menu.name?.toLowerCase()
)?.children || []
const items = (item:any) => {
return (
<ul className="p-2 z-50 bg-base-100 shadow-md">
{item.children.map((itemChild: any, idx: number) => {
return (
<li key={idx}>
<Link
to="#"
activeClassName="text-neutral-content hover:bg-submenu active:bg-allsubmenu z-50"
>
{itemChild.name}
</Link>
{(itemChild?.children.length > 0) && items(itemChild)}
<ul className={`menu menu-horizontal p-0 ${className}`}>
{menu?.map((item: any, key: number) => {
<svg
className="fill-current"
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
>
<path d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z" />
</svg>
)}
{item?.children.length > 0 && items(item)}
</li>
)
})}
</ul>
{/* END MENU MOBILE */}
</>
)
}