I'm trying to make a hamburger menu component that consists of links and (optionally) icons. I have chosen HeadlessUI to do this as I'm otherwise using Tailwind.
So I have some list of links in Astro front-matter in one file:
---
import HamburgerMenu from './HeadlessHamburger'
import { IoLogoGithub } from 'react-icons/io5'
const links = [
{ href: '/', label: 'Home' },
{ href: 'https://github.com', label: 'Github', icon: IoLogoGithub}
]
---
<div>
<HamburgerMenu client:visible links={links} />
</div>
Then in my HamburgerMenu.tsx file, I'm trying to do the following:
import type { IconType } from 'react-icons'
interface Props {
links: {
href: string
label: string
icon?: IconType
][]
}
export default function HamburgerMenu({ links }: Props) {
console.log('HamburgerMenu links prop:', links)
}
If I do this in my browser, I see that the Github link is coming through with a null icon:
{ href: "https://github.com", label: "Github", icon: null }
Am I going about this in the right way? Is there some sort of way I'm supposed to "instantiate" and pass that? My goal is to have a single, constant list of links that I can update and they will pass into this HamburgerMenu rendering component.