import { NavItem } from "../../types/nav.ts";
import { getNavItems } from "../../util/getNavItems.ts";

export function NavSection(props: { items: NavItem[] }) {
  return (
    <ul>
      {props.items.map((i) => (
        <li>
          {i.children
            ? <NavSection items={i.children} />
            : <a href={i.href} target={i.external ? "_blank" : ""}>{i.title}
            </a>}
        </li>
      ))}
    </ul>
  );
}

export function Nav() {
  const navItems = getNavItems();
  return (
    <NavSection
      items={navItems}
    />
  );
}
