import {useEffect, useRef, useState} from 'react' import Link from 'next/link' import { useRouter } from 'next/router' import clsx from 'clsx' import { AnimatePresence, motion, useIsPresent } from 'framer-motion' import { Button } from '@/components/Button' import { useIsInsideMobileNavigation } from '@/components/MobileNavigation' import { useSectionStore } from '@/components/SectionProvider' import { Tag } from '@/components/Tag' import { remToPx } from '@/lib/remToPx' function useInitialValue(value, condition = true) { let initialValue = useRef(value).current return condition ? initialValue : value } export function TopLevelNavItem({ href, children }) { return (
  • {children}
  • ) } export function NavLink({ href, tag, active, isAnchorLink = false, children }) { return ( {children} {tag && ( {tag} )} ) } export function VisibleSectionHighlight({ group, pathname }) { let height = remToPx(2) let offset = remToPx(0) let activePageIndex = group.links.findIndex((link) => link.href === pathname) let top = offset + activePageIndex * height return ( ) } export function ActivePageMarker({ group, pathname }) { let itemHeight = remToPx(2) let offset = remToPx(0.25) let activePageIndex = group.links.findIndex((link) => link.href === pathname) let top = offset + activePageIndex * itemHeight return ( ) } function NavigationGroup({ group, className, tableOfContents }) { // If this is the mobile navigation then we always render the initial // state, so that the state does not change during the close animation. // The state will still update when we re-open (re-render) the navigation. // let isInsideMobileNavigation = useIsInsideMobileNavigation() let router = useRouter() // let [router, sections] = useInitialValue( // [useRouter(), useSectionStore((s) => s.sections)], // isInsideMobileNavigation // ) let isActiveGroup = group.links.findIndex((link) => link.href === router.pathname) !== -1 return (
  • {group.title}
    {isActiveGroup && ( )} {isActiveGroup && ( )}
      {group.links.map((link) => ( {link.title} {link.href === router.pathname && ( {router.route.startsWith("/ipa/resources") && tableOfContents.tableOfContents.map((section) => (
    • {section.title}
    • ))}
      )}
      ))}
  • ) } export const apiNavigation = [ { title: 'Guides', links: [ { title: 'Quickstart', href: '/ipa/guides/quickstart' }, { title: 'Authentication', href: '/ipa/guides/authentication' }, { title: 'Errors', href: '/ipa/guides/errors' }, // { title: 'Events', href: '/accounts' }, ], }, { title: 'Resources', links: [ { title: 'Accounts', href: '/ipa/resources/accounts' }, { title: 'Users', href: '/ipa/resources/users' }, { title: 'Tokens', href: '/ipa/resources/tokens' }, { title: 'Peers', href: '/ipa/resources/peers' }, { title: 'Setup Keys', href: '/ipa/resources/setup-keys' }, { title: 'Groups', href: '/ipa/resources/groups' }, { title: 'Rules', href: '/ipa/resources/rules' }, { title: 'Policies', href: '/ipa/resources/policies' }, { title: 'Routes', href: '/ipa/resources/routes' }, { title: 'DNS', href: '/ipa/resources/dns' }, { title: 'Events', href: '/ipa/resources/events' }, ], }, ] export function NavigationAPI(tableOfContents, props) { return ( ) }