import Link from 'next/link' import { useRouter } from 'next/router' import clsx from 'clsx' import { AnimatePresence, motion } from 'framer-motion' import { Button } from '@/components/Button' import { Tag } from '@/components/Tag' import { remToPx } from '@/lib/remToPx' import {useEffect, useState} from "react"; import {NavigationStateProvider, useNavigationState} from "@/components/NavigationState"; export const apiNavigation = [ { title: 'Guides', links: [ { title: 'Quickstart', href: '/api/guides/quickstart' }, { title: 'Authentication', href: '/api/guides/authentication' }, { title: 'Errors', href: '/api/guides/errors' }, // { title: 'Events', href: '/accounts' }, ], }, { title: 'Resources', links: [ { title: 'Accounts', href: '/api/resources/accounts' }, { title: 'Users', href: '/api/resources/users' }, { title: 'Tokens', href: '/api/resources/tokens' }, { title: 'Peers', href: '/api/resources/peers' }, { title: 'Ingress Ports', href: '/api/resources/ingress-ports' }, { title: 'Setup Keys', href: '/api/resources/setup-keys' }, { title: 'Groups', href: '/api/resources/groups' }, { title: 'Policies', href: '/api/resources/policies' }, { title: 'Posture-Checks', href: '/api/resources/posture-checks' }, { title: 'Geo-Locations', href: '/api/resources/geo-locations' }, { title: 'Routes (deprecated)', href: '/api/resources/routes' }, { title: 'Networks', href: '/api/resources/networks' }, { title: 'DNS', href: '/api/resources/dns' }, { title: 'Events', href: '/api/resources/events' }, ], }, ] export function NavigationAPI({tableOfContents, className}) { return ( ) } export function TopLevelNavItem({ href, children }) { return (
  • {children}
  • ) } export function NavLink({ href, tag, active, isAnchorLink = false, children, links, isChildren = false }) { let router = useRouter(); return (
    {children} {tag && ( {tag} )} {links && }
    ) } export function flattenNavItems(links, onlyLinks = false) { let output = [] for (let link of links) { output.push(link) if (link.links) output.push(...flattenNavItems(link.links, onlyLinks)) } if(onlyLinks) output = output.filter((link) => link.href) return output } export function VisibleSectionHighlight() { const router = useRouter(); let height = remToPx(2) let offset = remToPx(0) const [activeIndex] = useNavigationState(); const [top, setTop] = useState(0); useEffect(() => { setTop(offset + (activeIndex) * height); }, [activeIndex, router.pathname]); return activeIndex >= 0 && ( ) } export function ActivePageMarker() { const router = useRouter(); let itemHeight = remToPx(2) let offset = remToPx(0.25) const [activeIndex] = useNavigationState(); const [top, setTop] = useState(0); useEffect(() => { setTop(offset + (activeIndex) * itemHeight); }, [activeIndex, router.pathname]); return activeIndex >= 0 && ( ) } function NavigationGroup({ group, className, tableOfContents }) { let router = useRouter() let isActiveGroup = group.links.findIndex((link) => link.href === router.pathname.replace("ipa", "api")) !== -1 return (
  • {group.title}
    {isActiveGroup && ( )} {isActiveGroup && ( )}
      {group.links.map((link) => ( {link.title} {link.href === router.pathname.replace("ipa", "api") && ( {router.route.startsWith("/ipa/resources") && tableOfContents?.map((section) => (
    • {section.title}
    • ))}
      )}
      ))}
  • ) }